SUM TEXTFIELD VALUES

F

Filiz Duman

Hi,
was just wondering how I can sum values from different textboxes,..
I used "+" but this adds the values together rather then creating a sum of
them.

e.g.

var x = document.clear.field1.value; (e.g. 10)
var y = document.clear.field2.value; (e.g. 11)

var sum = x + y (that comes up with 1011) rather then 21.
How can I add them together so the result is 21 ?
Any ideas.
Thanks
 
R

Randy Webb

Filiz said:
Hi,
was just wondering how I can sum values from different textboxes,..
I used "+" but this adds the values together rather then creating a sum of
them.

e.g.

var x = document.clear.field1.value; (e.g. 10)
var y = document.clear.field2.value; (e.g. 11)

var sum = x + y (that comes up with 1011) rather then 21.
How can I add them together so the result is 21 ?
Any ideas.
Thanks

http://www.jibbering.com/faq/#FAQ4_21

var sum = +x + +y;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top