Possible Duplicate:
JavaScript: formatting number with exactly two decimals
Can some one please help me with my java script?
My java script consistently counts up, the problem is the cents character length is way too long (need 2 characters max). Another problem is, I don't know what code additionally I need to put commas in the correct position for determining the proper amount. Example: 12345.67 vs 12,345.67. If some one can just take a look at the code, modify it and re-post the full code since I have no idea what to do, I would deeply appreciate it.
This is the javascript code: http://jsfiddle.net/pqsH6/
<p style="float:left;">Money Saved: </p><b><p id="ds" style="float:left;">$</p></b>
<div id="counter" style="float:left;"></div>
<script type="text/javascript">
var START_DATE = new Date("january 1, 2012 12:00:00"); // put in the starting date here
var INTERVAL = 1000; // savings per second
var INCREMENT = 0.005; // money saved per second
var START_VALUE = -50000; // configures proper savings calculation
var count = 0;
window.onload = function()
{
var msInterval = INTERVAL * 1;
var now = new Date();
count = parseInt((now - START_DATE)/msInterval) * INCREMENT + START_VALUE;
document.getElementById('counter').innerHTML = count;
setInterval("count += INCREMENT; document.getElementById('counter').innerHTML = count;", msInterval);
}
</script>