Link to home
Start Free TrialLog in
Avatar of Nemetona
Nemetona

asked on

addition operator syntax

In my code I have a line which multiplies one value by another and this works well - see attached code line
however, when I changed the code to add the two values together I get an error message
SCRIPT1004 Expected ;
Both the array value and the textfield values are numbers.  Can anyone explain why changing the * to a + is causing these problems and how can I resolve it.

Thanks
This first code works
_temp = eval(eval(document.getElementById('textfield'+j).value)*arr_ECL[i][_ind]);

This next code does not work
_temp = eval(eval(document.getElementById('textfield'+j).value)+arr_ECL[i][_ind]);

Open in new window

Avatar of mrcoffee365
mrcoffee365
Flag of United States of America image

I'm sure you don't want Java Server Pages as your zone -- you want to ask Javascript experts on this.  Click on the Request Attention link above to ask the moderator to change the zones on this question.

"+" is also used for concatenating strings -- is it possible that Javascript is trying to append a string in the "+" case, and that isn't working?

What you might want to do is separate the actions so that Javascript can do the right thing before you try to do the match.
Sorry -- "do the math" not "match."
ASKER CERTIFIED SOLUTION
Avatar of chaitu chaitu
chaitu chaitu
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial