♥ Love Us:

Summing up fields

Does anyone know why this script does not work??? thisitem = eval(price1.getText())+(price2.getText()); itemtot1.setText(thisitem); When I use ut, it adds the numbers together instead of giving me a sum of them. Thanks.

Last updated 10 years ago by did

You must be logged in to answer or post comments to this question.

Click here to login now.

Comments

Isn't adding and summing the same thing?
Posted by Matthew Pomar 12 years ago
This is a common mistake, you are concatenating the strings. The change you need is this: thisitem = parseInt(price1.getText())+parseInt(price2.getText()); itemtot1.setText(thisitem); It first changes the string values into integer values and THEN sums them together.
Posted by did 10 years ago

ExpertHelp LLC is an independent provider of professional support services for 3rd party products and services. Any use of 3rd party trademarks, brand names, products and services is only referential and ExpertHelp LLC hereby disclaims any sponsorship, affiliation or endorsement of or by any such 3rd party.