Solved
Round parseFloat number value to two deciml points
Posted on 2003-12-08
I have a function that does some math, and am using parseFloat. The value it returns must be rounded to two decimal places. I have tried Math.Round(value) but it returns nothing. Is this because math.round does not work with parseFloat? The script uses two fields, and is as follows:
function totalFields()
{
myTotal1 = document.myForm.before.value;
myTotal2 = document.myForm.after.value;
myBigTotal = [(parseFloat(myTotal1)-parseFloat(myTotal2))*100]/parseFloat(myTotal1);
return(myBigTotal)
}
function addemup()
{
document.myForm.grandtotal.value=totalFields();
}
How can I convert the value to something recognized by math.round(value), or is there another way of converting this to two decimal points? A test value could be 12.55658334973432
Thanks in advance,
lance22
JavaScript Noob