| |||||||
| Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics. |
![]() |
| | LinkBack | Thread Tools |
| | #1 (permalink) |
| NamePros Regular | 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>
__________________ Jefferson General Store Save Money On Gas! Terminator4.org - Who should replace Arnold? Last edited by ATWatts; 09-12-2005 at 07:06 AM. |
| |
| | #2 (permalink) |
| Senior Member | 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>
|
| |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| |
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 |