Welcome to WebmasterWorld Guest from

Forum Moderators: open

Message Too Old, No Replies


decimal point in JavaScript



7:48 am on Mar 5, 2003 (gmt 0)

10+ Year Member

I'm new to JS and I figured out how to do an online order form but I donít know how to reduce the decimal point to 2 decimal points, or round up ($104.92). The sales tax in my state is .086 and after multiplying by the Subtotal I get some pretty long numbers on my tax total based on the item chosen. Can anyone help?

Subtotal: $1220

Tax: $104.91999999999999

Total: $1324.92


8:14 am on Mar 5, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member

That's an oddball tax rate. ;)

var subtotal = 1220;
var taxrate = .086;
var tax = Math.round((subtotal * taxrate)*100)/100;
var total = subtotal + tax;

Hope this helps.


9:04 am on Mar 5, 2003 (gmt 0)

10+ Year Member

Thank you so much Key_Master. I"m new at JS but i'm starting to get the hang of it. I just stumbled onto webmasterworld tonight and i can see it's going to be very useful thanks to people like you :-)

Thanks again!


Featured Threads

Hot Threads This Week

Hot Threads This Month