Possible Duplicate:
how to print number with commas as thousands separators in Javascript
I have found a few posts along these lines but none of them provide the solution i'm looking for. I have a number variable that is being output to a page using document.write
.
I need to comma separate this value, is there an efficient way to insert a comma after every third number (ex: 256012 to 256,012).
Here is my js in full:
//vars declared (located top of page)<br />
var miles = 256012;//miles completed<br />
var progress = (miles / 477714) * 100;
//output var (into page content)<br />
<script>document.write (miles);</script> Miles Complete
//adjust width of progress bar according to % complete (bottom scripts)<br />
function rtmProgressBar (ObjectID, Value){<br />
document.getElementById(ObjectID).style.width = Value.toString() + "%";<br />
}<br />
rtmProgressBar("rtm-progress-wrap", progress);
Any insight would be greatly appreciated.