[advanced search]
 

Go Back   NamePros.com > Discussion > Web Design & Development > Programming

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.


Closed Thread
 
LinkBack Thread Tools
Old 09-12-2005, 07:01 AM   #1 (permalink)
NamePros Regular
 
Join Date: Aug 2003
Location: Texas
Posts: 382
60.80 NP$ (Donate)

ATWatts is on a distinguished road


Simple Java Question -19NP reward

How do you limit the number of digits that are displayed when outputting a number using Java. FOr example instead of 23.032345434 I want to display 23.03.

I'm trying to limit the digits shown on my little calculator at www.GasCreditCard.biz.

19 NP to whoever answers my question correctly first. That means that the answer directly has to lead to my problem being fixed.

Code:
function calculatesavings(form)
{
MPG = form.MPG.value;
MDPY = form.MDPY.value;
PPG = form.PPG.value;
GTS = form.GTS.value;
G=MDPY/MPG;
CWS=G*PPG;
SPY=CWS*.1;
SPM=SPY/12;
SPG=.1*PPG;
SPT=SPG*GTS;
form.SPY.value=SPY;
form.SPM.value=SPM;
form.SPT.value=SPT;
form.SPG.value=SPG;
}
</script>

Last edited by ATWatts; 09-12-2005 at 07:06 AM.
ATWatts is offline  
Old 09-12-2005, 08:37 AM   #2 (permalink)
Senior Member
 
dgaussin's Avatar
 
Join Date: May 2004
Location: France
Posts: 1,294
85.60 NP$ (Donate)

dgaussin is a splendid one to beholddgaussin is a splendid one to beholddgaussin is a splendid one to beholddgaussin is a splendid one to beholddgaussin is a splendid one to beholddgaussin is a splendid one to beholddgaussin is a splendid one to behold


Try that :

Code:
function calculatesavings(form)
{
MPG = form.MPG.value;
MDPY = form.MDPY.value;
PPG = form.PPG.value;
GTS = form.GTS.value;
G=MDPY/MPG;
CWS=G*PPG;
SPY=CWS*.1;
SPM=SPY/12;
SPG=.1*PPG;
SPT=SPG*GTS;
form.SPY.value=Math.round(SPY*100)/100;
form.SPM.value=Math.round(SPM*100)/100;
form.SPT.value=Math.round(SPT*100)/100;
form.SPG.value=Math.round(SPG*100)/100;
}
</script>
dgaussin is offline  
Old 09-12-2005, 12:50 PM   #3 (permalink)
NamePros Regular
 
Join Date: Aug 2003
Location: Texas
Posts: 382
60.80 NP$ (Donate)

ATWatts is on a distinguished road


Thanks

Thanks!!
ATWatts is offline  
Closed Thread


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

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

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
simple domain question 4 non newbies rcep Domain Newbies 0 08-21-2005 12:52 PM
Simple but silly question - Paths/tags geezdesign Programming 7 07-03-2004 12:43 PM
Simple image question ccc Web Design Discussion 3 06-19-2004 12:31 PM

Site Sponsors
Advertise your business at NamePros

All times are GMT -7. The time now is 12:50 AM.


Powered by: vBulletin® Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0
Template-Modifications by TMS
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios

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 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85