| | |||||
| ||||||||
| Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics. |
![]() |
| | LinkBack | Thread Tools |
| | THREAD STARTER #1 (permalink) |
| NamePros Regular Join Date: Aug 2003 Location: Texas
Posts: 384
![]() | 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. ????: NamePros.com http://www.namepros.com/programming/123035-simple-java-question-19np-reward.html 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 08:06 AM.
|
| |
| | #2 (permalink) |
| Senior Member Join Date: May 2004 Location: France
Posts: 1,226
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | 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 01:52 PM |
| Simple but silly question - Paths/tags | geezdesign | Programming | 7 | 07-03-2004 01:43 PM |
| Simple image question | ccc | Web Design Discussion | 3 | 06-19-2004 01:31 PM |