homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

decimal point in JavaScript

 7:48 am on Mar 5, 2003 (gmt 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)

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)

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!

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved