Wednesday, March 16, 2011

Javascript Rounding

I had a javascript calculation that was displaying a ton of decimal points.

 

Here is a way to round to 2 decimal places in Javascript:

 

 

var total = 123.433

total = Math.round(total*100)/100  //returns 123.43

Credit Goes to Javascript ToolKit