|
|
Q131 How do I add form elements together, I have tried many different ways but I always either get NaN or a concenated string (ie 15 + 16 + 1 + 52 = 1615152 != 84)?
irt.org | Knowledge Base | JavaScript | Form 6 | Q131 [ previous next ] Q131 How do I add form elements together, I have tried many different ways but I always either get NaN or a concenated string (ie 15 + 16 + 1 + 52 = 1615152 != 84)?Try
Ray Pooley writes: Use parseInt() or parseFloat() methods to assign the form text variables to numeric variables and perform your maths on the new variables. eg: numvar = parseFloat(formelementvalue); If formelementvalue contains '30.1' then numvar will be equal to 30.1 numeric. Feedback on 'Q131 How do I add form elements together, I have tried many different ways but I always either get NaN or a concenated string (ie 15 + 16 + 1 + 52 = 1615152 != 84)?' |
-- div -->
|