| | |
Currency usage in calculator form
Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved
![]() |
•
•
Join Date: Sep 2008
Posts: 2
Reputation:
Solved Threads: 0
I need some help. I am modifying a script that I wrote some time ago that uses JavaScript to calculate a return on investment. The script works pretty well but it sometimes returns values with an infinate number of digits past the decimal. Since this calculator is dealing with money values, I only need two digits past the decimal rounded appropriately. Can anyone help?
Thanks,
Larry
Thanks,
Larry
•
•
Join Date: Sep 2008
Posts: 2
Reputation:
Solved Threads: 0
Well, after a lot of searching, I found a solution to my problem. I wanted to post it in case it can help someone else. What I did was I had the code get a variable or variables, perform the needed calculations on them and then rounded the result before returning the results to the form. I am only posting part of the code so that it is not confusing.
{code}
totladdprof = rgprofit + wfcyear; //calculating the total additional profit
var totladdprofrnd=Math.round(totladdprof*100)/100 //rounds results of total additional profit
form.TotalAddProfit.value = totladdprofrnd; //sending the total additional profit to form
{/code}
Thanks,
Larry
{code}
totladdprof = rgprofit + wfcyear; //calculating the total additional profit
var totladdprofrnd=Math.round(totladdprof*100)/100 //rounds results of total additional profit
form.TotalAddProfit.value = totladdprofrnd; //sending the total additional profit to form
{/code}
Thanks,
Larry
![]() |
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: Iframe reload with setTimeout
- Next Thread: Ajax script not working on firefox
| Thread Tools | Search this Thread |
acid2 ajax ajaxcode ajaxexample ajaxhelp ajaxjspservlets animate automatically beta box browser bug captchaformproblem checkbox close codes createrange() css cursor debugger decimal dependent disablefirebug dom download dropdown editor element engine error events explorer ext file firefox form forms frameworks getselection google gwt gxt hiddenvalue highlightedword hint html htmlform ie7 ie8 iframe index internet java javascript javascripthelp2020 jawascriptruntimeerror jquery jsf jsfile jsp jump listbox maps masterpage math media microsoft mp4 object onmouseoutdivproblem onreadystatechange paypal pdf php player position programming progressbar prototype redirect regex runtime safari scale scriptlets search security select size software sql text textarea unicode w3c window windowofwords windowsxp wysiwyg \n





