-----Original Message-----
-----Original Message-----
Hi there
Howdy.
Is there a way to + or x the values in two text boxes?
For instance, lets say you have 3 text boxes in a form,
can you, using frontpage 2003 forms, take the number or
value in textbox1 + or x it to the value in textbox2 and
have the results show up in textbox3. If so, How?
Suppose you have three text boxes named txtQty, txtPrc,
and txtTot. Add the following script to your <head>
section:
<script>
function calcTot(){
var nQty = parseFloat(document.forms[0].txtQty.value);
var nPrc = parseFloat(document.forms[0].txtPrc.value);
if (isNaN(nQty) || isNaN(nPrc)){
document.forms[0].txtTot.value="";
return;
}
document.forms[0].txtTot.value =nQty * nPrc;
}
</script>
adn then call the function every time the value of either
the txtQty or txtPrc text boxe changes. The code for the
three text boxes would then look like this.
<input type="text" name="txtQty" size="20"
onchange="calcTot();">
<input type="text" name="txtPrc" size="20"
onchange="calcTot();">
<input type="text" name="txtTot" size="20">
Keep in mind, though, that the Web visitor can turn off
JavaScript, or easily modify the code to produce
incorrect answers.
Jim Buyens
Microsoft FrontPage MVP
http://www.interlacken.com
Author of:
*----------------------------------------------------
|\---------------------------------------------------
|| Microsoft Office FrontPage 2003 Inside Out
||---------------------------------------------------
|| Web Database Development Step by Step .NET Edition
|| Microsoft FrontPage Version 2002 Inside Out
|| Faster Smarter Beginning Programming
|| (All from Microsoft Press)
|/---------------------------------------------------
*----------------------------------------------------
.