Hello I found this function here yesterday and while it works great for values of only 1 decimal place, when I get a value with no decimal place it doesn't work. Can some one help me modify this.
I'm using Math.round and if I get 65, I need it to display 65.00
Thanx
I'm using Math.round and if I get 65, I need it to display 65.00
Code:
function numberFormat(str)
{
str = str.toString();
if(str.indexOf(".") == -1)
{
return str;
}
splitString = str.split(".");
var newSplitString = splitString[1];
for(i=0; i < (2 - splitString[1].length); i++)
{
newSplitString = newSplitString + "0";
}
return (splitString[0] + "." + newSplitString);
}
Thanx