Use "parseFloat" for a floating point # instead of "parseInt" for an integer value in the script
| Works well, but being $ amounts it does not show the cents only adds the
| full dollars
|
| Thanks
| Graham
|
| | > Here's a very simple script that should work for you. I've matched the
| > casing for form and control names, so you should be able to paste it into
| > your web page without too many modifications, if any. Put it in the HEAD
| > section of the page on which the form is located.
| >
| > <script>
| > function CalculateTotal()
| > {
| > var fm = document.FrontPage_Form1;
| > var amt1 = document.FrontPage_Form1.Amount1;
| > var amt2 = document.FrontPage_Form1.Amount2;
| > var amt3 = document.FrontPage_Form1.Amount3;
| > var ttl = document.FrontPage_Form1.Total;
| > var iAmt1 = 0;
| > var iAmt2 = 0;
| > var iAmt3 = 0;
| >
| > if (amt1.value != "")
| > {iAmt1 = parseInt(amt1.value);}
| > if (amt2.value != "")
| > {iAmt2 = parseInt(amt2.value);}
| > if (amt3.value != "")
| > {iAmt3 = parseInt(amt3.value);}
| >
| > ttl.value = iAmt1 + iAmt2 + iAmt3;
| > }
| > </script>
| >
| > Then you need to put the following event handler in each of the Amount
| > control in the form
| >
| > onchange=CalculateTotal();
| >
| > So that the control looks like
| >
| > <input type="text" name="Amount1" onchange=CalculateTotal();>
| >
| > Once you've done that, preview in the browser and enter numbers into the
| > amount controls. The number in the total box should change everytime you
| > change one of the amount numbers.
| >
| > --
| > Lisa Wollin
| > Programmer Writer
| > Microsoft Corporation
| > | > > I have created a form named 'FrontPage_Form1' I have three fields called
| > > 'Amount1' , 'Amount2' and 'Amount3'. What I want to do is have a field
| > that
| > > adds the three amounts as they are entered and show the value in a field
| > > called 'Total'. This form saves to an Access database.
| > >
| > > Is there a simple script that I can add to the page to do this and where
| > > abouts do I add it in the html code. I have searched many of the FP
| > support
| > > sites but none have a simple script to accomplish this task
| > >
| > > Thanks
| > > Graham
| > >
| > >
| >
| >
|
|