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
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]);
Sorry -- "do the math" not "match."
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
"+" 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.