double field value in javascript

Results 1 to 2 of 2

Thread: double field value in javascript

  1. #1
    Join Date
    Dec 1969

    Default double field value in javascript

    Bill W helped me with javascript. Now how can I change the code to calcualte the tax so that is shows the decimal value. Then calcualte the total accordingly. <BR><BR>Currently it works like this when I select <BR>412 it shows sales tax as 3399 and tota as 3911 <BR><BR><BR><BR>&#060;SCRIPT&#062; <BR>function recalcTotal( frm ) <BR>{ <BR> taxrate = 8.25 <BR> var fee = parseFloat( radioGroupValue( frm.fee ) ); <BR> var rental = parseFloat( radioGroupValue( frm.rental ) ); <BR> var salestax = parseFloat(taxrate * ( fee + rental ) ); <BR>var subtotal = fee + rental ; <BR> document.frm.subtotal.value = subtotal; <BR>document.frm.salestax.value = salestax; <BR> = fee + rental + salestax ; <BR>} <BR>&#060;/SCRIPT&#062; <BR><BR>=== <BR>Form looks like this. <BR>&#060;form name=frm action="formprocess.asp" method="POST"&#062; <BR><BR>&#060;input type=radio name=rental value=375&#062;375 <BR>&#060;input type=radio name=rental value=475&#062;475 <BR><BR><BR> <BR>&#060;input type=radio name=fee value=37 onClick="recalcTotal( frm ) ;"&#062;37 <BR>&#060;input type=radio name=fee value=47 onClick="recalcTotal( frm ) ;"&#062;47 <BR><BR><BR><BR> <BR>Sub Total: &#060;input type=text name=subtotal&#062;<BR> <BR>Sales Tax: &#060;input type=text name=salestax&#062;<BR> <BR>Total: &#060;input type=text name=total&#062;<BR> <BR><BR>Thanks in advance<BR>

  2. #2
    Join Date
    Dec 1969

    Default Your tax rate is wrong...

    8.25 for a tax rate would be 825%<BR><BR>You want 0.0825 for the tax rate. The percentage divided by 100.<BR><BR>5th grade math.<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts