Source Code of: addtotals.htm
Date Last Modified: May 02, 2009 - 01:59:17 AM
Size: 1 KB  |  46 lines  |  1,967 characters
<html>
<head>
<script type="text/javascript">
   function addTotals()
   {
      var amount1;
      var amount2;
      var amount3;
      var amount4;
      var amount5;
      
      var surcharge;
      var dollarTotal;
      
      /* Retrieve current field values */
      amount1 = document.forms['finance1'].generalDonation_amount.value-0;
      amount2 = document.forms['finance1'].specificPayment_amount.value-0;
      amount3 = document.forms['finance1'].staffDonation_amount.value-0;
      amount4 = document.forms['finance1'].studentDonation_amount.value-0;
      amount5 = document.forms['finance1'].schoolFees_amount.value-0;
      
      /* Calculate total amount and surcharge */
      dollarTotal = amount1 + amount2 + amount3 + amount4 + amount5;
      surcharge = dollarTotal * .02;
      
      /* Update and display values in surchage and total fields */
      document.forms['finance1'].finance_creditCard_surcharge.value = surcharge;
      document.forms['finance1'].finance_totalAmount.value = dollarTotal + surcharge;
   }    
</script>
</head>
<body>
<h3>onKeyUp="addTotals();"</h3>

<form name="finance1" method="post" action="#" />
   Amount 1: <input type="text" name="generalDonation_amount" id="amount1" size="10" onkeyup="addTotals();" /><br/>
   Amount 2: <input type="text" name="specificPayment_amount" id="amount2" size="10" onKeyUp="addTotals();" /><br/>
   Amount 3: <input type="text" name="staffDonation_amount" id="amount3" size="10" onKeyUp="addTotals();" /><br/>
   Amount 4: <input type="text" name="studentDonation_amount" id="amount4" size="10" onKeyUp="addTotals();" /><br/>
   Amount 5: <input type="text" name="schoolFees_amount" id="amount5" size="10" onKeyUp="addTotals();" /><br/><br/>
   Surcharge (2%): <input type="text" name="finance_creditCard_surcharge" id="twopercent" size="10" value="" /><br/>

   TOTAL: <input type="text" name="finance_totalAmount" id="total" size="10" value="" />
</form>
</body>
</html>

A Derivative Work of: PHP Source Code Utility - Version 1.0.0 Copyright © 0php.com 2002.