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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding up totals on an order form

Status
Not open for further replies.

DH

Programmer
Dec 8, 2000
168
Using javascript I have created an order form where the user enters the quantity for various products. Once the quantity is entered the total for each product is calculated automatically. At the end of the order form I have a Grand Total that adds the product totals together.
All works fine except that the grand total shows many digits to the right of the decimal point such as $59.1200000. Any suggestions on how to limit the digits to the right of the decimal place to 2 such as $59.12? Is there a rounding command or something?



 
there is a Math.round() method, but it would eliminate the .12 as well. You can write a function something like this:

tmpar=myvalue.split(".")
afterdecimal=tmpar[1].substring(0,2)

that will give you only the first 2 digits after the decimal point, but you may lose precision... jared@aauser.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top