Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Sum of the checkbox values at each time select the checkbox. in Php

                    Sum of the Checkbox values are basically classified into two types.

1. As direct sum of the no. of checkboxes.
2. As sum of the checkboxes at each time select the checkbox values.

Briefly On As sum of the checkboxes at each time select the checkbox values.

Step1:
In this, you have to write some javascript first the javascript as follows, which is to paste in your head tag.


<!--step1 -->
<script language="javascript">
function app()
{
if(f1.installment_1.checked==true)
$x=500;
else< $x=0;
if(f1.installment_2.checked==true)
$y=600;
else
$y=0;
if(f1.installment_3.checked==true)
$z=700;
else
$z=0;
if(f1.installment_4.checked==true)
$a=800;
else
$a=0;
if(f1.installment_1.checked f1.installment_2.checked
f1.installment_3.checked f1.installment_4.checked==true)
{
$sum=$x+$y+$z+$a;
f1.amt.value=$sum;
}
else
f1.amt.value=0;
}
</script>


Step2:
In this, you have to paste below code in html body tag as you see a function is called at each checkbox.


<!--step2 -->
<td>
<label>
<input onclick="app()" type="checkbox" value="500" name=" installment_1">
Term_1
</label></td>
<td><label>
<input onclick="app()" type="checkbox" value="600" name=" installment_1">
Term_1
</label></td>
<td>
<label>
<input onclick="app()" type="checkbox" value="700" name=" installment_1">
Term_1</label></td>
<td>
<label>
<input onclick="app()" type="checkbox" value="800" name=" installment_1">
Term_1
</label></td>

Step3:
In this, you display the sum of the checkbox value where you want to display here i am display the total in a text box.


<!--step3 -->
<td>& Amount&</td>
<td><input name="amt" type="text" size="10" readonly="readonly"></td>
Over to you.


This post first appeared on Php Source Codes, please read the originial post: here

Share the post

Sum of the checkbox values at each time select the checkbox. in Php

×

Subscribe to Php Source Codes

Get updates delivered right to your inbox!

Thank you for your subscription

×