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: TKArtist is an unknown quantity at this point 
Solved Threads: 0
TKArtist TKArtist is offline Offline
Newbie Poster

Currency usage in calculator form

 
0
  #1
Sep 11th, 2008
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
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 954
Reputation: essential will become famous soon enough essential will become famous soon enough 
Solved Threads: 131
Featured Poster
essential's Avatar
essential essential is offline Offline
Posting Shark

Re: Currency usage in calculator form

 
0
  #2
Sep 11th, 2008
Hi there!
It would be nice if i can see the code...
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 2
Reputation: TKArtist is an unknown quantity at this point 
Solved Threads: 0
TKArtist TKArtist is offline Offline
Newbie Poster

Re: Currency usage in calculator form

 
0
  #3
Sep 15th, 2008
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
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Other Threads in the JavaScript / DHTML / AJAX Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC