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

NemetonaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mrcoffee365Commented:
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.
0
mrcoffee365Commented:
Sorry -- "do the math" not "match."
0
chaitu chaituCommented:
try this.
parseInt(document.getElementById('textfield'+j).value)+parseInt(arr_ECL[i][_ind]); 

Open in new window


0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JSP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.