Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I loose a penny each time I check/uncheck a box

Status
Not open for further replies.

RoboPunk

Technical User
Aug 15, 2000
1
US
I am modifying an order page script so that it will add sales tax to the total. I added the function to do so and when I tested the page it looked like everything worked, but when you check a product with cents other than .00 in the price and then un-check the sales tax box &quot;Do you live in MD?&quot; the total would loose a penny. And every time after that you check and un-check the sales tax box, the total will loose a penny each time. Any help with this problem would be very appreciated.<br>The script's URL is:<br><A HREF=" TARGET="_new"> <br><br>Thank you,<br>Nathan
 
RoboPunk,

Since your script's fairly big and I don't feel like heavy debugging I'll offer just a few suggestions:
* the problem's probably in the fix() function which the Salestax() function calls.
* successive multiplication and division on the same number (the total sales value) always has a risk of rounding error. It's safer to work out the total from the raw data each time. If that's not possible, keep separate pre-tax and post-tax figures, and work out the post-tax figure afresh from the pre-tax figure every time the &quot;Maryland&quot; checkbox changes.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top