01.
<form name=
"frm"
>
02.
<p><input type=
"checkbox"
id=
"checkbox"
value=
"1"
onclick=
"tick(frm)"
/> 1</p>
03.
<p><input type=
"checkbox"
id=
"checkbox"
value=
"2"
onclick=
"tick(frm)"
/> 2</p>
04.
<p><input type=
"checkbox"
id=
"checkbox"
value=
"3"
onclick=
"tick(frm)"
/> 3</p>
05.
<p><input type=
"checkbox"
id=
"checkbox"
value=
"4"
onclick=
"tick(frm)"
/> 4</p>
06.
<input type=
"text"
name=
"sum"
id=
"sum"
value=
"0"
/>
07.
<hr>
08.
<p><input type=
"checkbox"
id=
"checkbox1"
value=
"1"
onclick=
"tick1(frm1)"
/> 1</p>
09.
<p><input type=
"checkbox"
id=
"checkbox1"
value=
"2"
onclick=
"tick1(frm1)"
/> 2</p>
10.
<p><input type=
"checkbox"
id=
"checkbox1"
value=
"3"
onclick=
"tick1(frm1)"
/> 3</p>
11.
<p><input type=
"checkbox"
id=
"checkbox1"
value=
"4"
onclick=
"tick1(frm1)"
/> 4</p>
12.
<input type=
"text"
name=
"sum1"
id=
"sum1"
value=
"0"
/>
13.
</form>
14.
<script type=
"text/javascript"
>
15.
function
tick( frm )
16.
{
17.
var
sum=0;
18.
for
(
var
i = 0; i < frm.elements.length; i++) {
19.
var
chk = frm.elements[i];
20.
if
( chk.type ==
'checkbox'
&& chk.checked )
21.
{
22.
sum += parseFloat( chk.value );
23.
};
24.
};
25.
frm.sum.value = sum;
26.
}
27.
28.
function
tick1(frm1)
29.
{
30.
var
sum1=0;
31.
for
(
var
i1 = 0; i1 < frm1.elements.length; i1++) {
32.
var
chk1 = frm1.elements[i1];
33.
if
( chk1.type ==
'checkbox1'
&& chk1.checked )
34.
{
35.
sum1 += parseFloat( chk.value );
36.
};
37.
};
38.
frm1.sum1.value = sum1;
39.
}
40.
</script>