<script type="text/javascript">
var m$ = jQuery.noConflict();
m$(document).ready(function(){
num = 623000;
prev = 623556;
subtract = num - prev;
subtract /= 24;
subtract /= 60;
subtract /= 60;
var timerID = setInterval(function() {
if(num > 0){
subtract *= 1000;
subtract = Math.round(subtract);
subtract /= 1000;
num -= subtract;
num *= 10000;
num /= 10000;
num = Math.round(num).toFixed(3);
m$('.dynamic').html(addCommas(num));
}
else {
clearInterval(timerID);
}
}, 1000 );
});
function addCommas(nStr){
nStr += '';
x = nStr.split('.');
x1 = x[0];
x2 = x.length > 1 ? '.' + x[1] : '';
var rgx = /(\d+)(\d{3})/;
while (rgx.test(x1)) {
x1 = x1.replace(rgx, '$1' + ',' + '$2');
}
return x1 + x2;
}
</script>
It a ticker that updates every second by subtracting the variable subtract from num. Unfortunately it no longer ticks down. I had it ticking just fine when I wasn't trying to do toFixed() to keep the zeros in the decimal place.
I Googled this and it said that I should use a string by doing the following:
numstr = Math.round(num + "").toFixed(3);
And that didn't work either, at one point I was getting NaN.