Welcome to WebmasterWorld Guest from 54.144.107.83

Forum Moderators: open

Message Too Old, No Replies

JavaScript

decimal point in JavaScript

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

New User

10+ Year Member

joined:Mar 5, 2003
posts:2
votes: 0


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)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:July 27, 2001
posts:1472
votes: 0


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)

New User

10+ Year Member

joined:Mar 5, 2003
posts:2
votes: 0


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!

 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members