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 ?
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 ?
- Please check I think you are adding any string in expression. – Vijay Verma Commented Dec 3, 2012 at 8:15
- this can help to some extent stackoverflow./questions/10473994/… – ankur Commented Dec 3, 2012 at 8:18
1 Answer
Reset to default 17Remove the mas, obviously:
parseFloat(value1.replace(/,/g,''))