I have a function that sums a column of data in an html table. It does so admirably only I would like to have it put the commas in there that are needed to separate the thou
I know this is an uber old post and has good answers, BUT if anyone is interested, there is a jQuery plugin which simplifies number formatting (thousands formatting, number of decimal places, custom thousands separator, etc) by making an include and a simple call. Has lots of features and documentation is enough. It's called jQuery Number.
You just include it:
And then use it:
On an automatic formatting HTML input: $('input.number').number( true, 2 );
or
On a JS call: $.number( 5020.2364, 2 ); // Outputs: 5,020.24
Hopefully this helps someone.