Page 1 of 1

calculate sum of all text boxes

Posted: Wed May 11, 2011 10:49 pm
by ishakya
hi everyone,

i need to calculate the sum of all text boxes in to a single text box.
assume:
text box1=100, totaltextbox should be 100,
If i enter,
textbox1=250,textbox2=200.When i enter value to the textbox1,total should be 250.once i enter the second value to the textbox2,total should change to 450.it just like a onchange function.
this is not happening when i press submit button.it should happen automatically.When i leave the textbox1,total should display the value of text box1.then i enter textbox2,total should be the sum of textbox 1 & textbox 2.
Hope everyone got my point.
Please help me to solve this as soon as possible.
thanks in advance.......

Re: calculate sum of all text boxes

Posted: Fri May 13, 2011 2:12 pm
by tr0gd0rr
Basic idea: you'll want to use JavaScript's document.getElementsByTagName('input') and iterate through results. If input.type == 'text', add input.value to the total.

Re: calculate sum of all text boxes

Posted: Sun May 15, 2011 10:35 pm
by ishakya
can you explain it more please?Because i have less knowledge in javascript


Thanks in advance

Re: calculate sum of all text boxes

Posted: Mon May 16, 2011 2:43 pm
by tr0gd0rr