I have four HTML fields, I grab their values and add them, in an equation that looks like this:
Total = Number(value1) + Number(value2) + Number(value3) + Number(value4)
Now some of the values might be equal to 1,078.00
, I get NaN
as a result. What should I do ?
Answer
Remove the commas, obviously:
parseFloat(value1.replace(/,/g,''))
No comments:
Post a Comment