Page 1 of 1

calculate sum of all text boxes

Posted: Mon May 09, 2011 11:10 pm
by ishakya
hi,
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.
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: Tue May 10, 2011 2:45 am
by zyntrax
If you mean dynamically, then i guess you have to use Java.

Re: calculate sum of all text boxes

Posted: Tue May 10, 2011 3:16 am
by ishakya
no this is not happening dynamically.Totally i got 30 text boxes.i need to calculate sum of that 30 text boxes.But sometimes user might enter all the text boxes or few of them. do you have any idea to do that?

Re: calculate sum of all text boxes

Posted: Tue May 10, 2011 8:33 am
by oscardog
Wrong section. Try posting it in the JavaScript section.

Re: calculate sum of all text boxes

Posted: Tue May 10, 2011 10:50 am
by AbraCadaver
Using PHP and calculating on submit, you would name your text boxes like so: name="textbox[]". Then on the resulting page you can sum them all:

Code: Select all

$total = array_sum($_POST['textbox']);
Dunno if that's what you're going for.