home hardware prices news articles forums photos user reviews
Go Back   Tech Support Forums - TechIMO.com > PC Hardware and Tech > Webmastering and Programming
Join TechIMO for Free!
Register Blogs FAQ Members List Calendar Search Today's Posts Mark Forums Read
Reply Get bargains at  »  Dealighted.com
 
Thread Tools
Currently Active Users: 2944
Discussions: 188,378, Posts: 2,243,454, Members: 232,606
Old November 4th, 2002, 11:54 PM   Digg it!   #1 (permalink)
Junior Member
 
Join Date: Nov 2002
Posts: 1
Quick javascript question

Hey everyone, I found these forums though a search on google, so I'm hoping somebody here can help me out. I'm all but completely new to javascript, and I've coded myself a nice little form calculating the prices of some items. The problem I run into is that the prices (once taxes are calculated) have decimal places, and many of them. How can I limit numbers to two decimal places? (I know how to round them to the nearest integer, but not to 2 decimal places).

Thanks in advance for any help you can provide

NineOne is offline   Reply With Quote
Old November 5th, 2002, 12:08 AM     #2 (permalink)
Anime Otaku
 
RobRich's Avatar
 
Join Date: Oct 2001
Location: Tampa, FL USA
Posts: 105,511
Blog Entries: 15
Welcome to TechIMO!

This link will likely prove quite helpful for your problem:

http://www.javascriptkit.com/javatutors/round.shtml

1) Multiple the original number by 10^x (10 to the power of x)
2) Apply Math.round() to the result
3) Divide result by 10^x

Hope this helps,
Robert Richmond
__________________
Robert Richmond | TechIMO Editor-in-Chief
Infinite perceptions. One reality.
FanFiction.Net - Unleash your imagination.

RobRich is offline   Reply With Quote
Old November 5th, 2002, 12:35 AM     #3 (permalink)
Ultimate Member
 
Join Date: Oct 2001
Posts: 21,017
Welcome to TechIMO

another option I found...
http://www.sonofsofaman.com/hobbies/...atcurrency.asp

vass0922 is online now   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may post new threads
You may post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Most Active Discussions
Is It Just Me? (2883)
The United States Debt (20)
Looks like Burris will get his Sena.. (8)
I think I just killed my computer w.. (24)
Upgrading RAM (5)
Folderchat Weekday thread (439)
Antec 300 bulk purchase? (11)
Worth the upgrade?? (14)
Titan quest and Immortal Throne, an.. (17)
Recent Discussions
New Build ( Finally ) (1)
dual monitors wont boot (0)
Folderchat Weekday thread (439)
MSN Hotmail Down??? (7)
Help with an Ati Radeon HD 4850.. (23)
Laptop waking up itself (0)
CPU wont boot (3)
Best digital camera for under 2.. (13)
Building first computer, will t.. (2)
Blackberry Storm, Gears of War .. (1)
Core 2 Quad Q9550 system (3)
COWBOOM Ripoff! Used Laptop w/$.. (4)


All times are GMT -4. The time now is 08:24 PM.
TechIMO Copyright 2008 All Enthusiast, Inc.



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28