01.
<html>
02.
<head>
03.
<title></title>
04.
</head>
05.
<body>
06.
<script language=
"javascript"
>
07.
function
fnccheck(){
08.
var
t1;
09.
var
t2;
10.
var
sum;
11.
if
(document.form1.chk1.checked == true){
12.
t1=parseFloat(document.form1.text1.value);
13.
14.
}
else
{
15.
t1=null;
16.
17.
}
18.
if
(document.form1.chk2.checked == true){
19.
t2=parseFloat(document.form1.text2.value);
20.
21.
}
else
{
22.
t2=null;
23.
24.
}
25.
26.
sum=t1+t2;
27.
document.form1.total.value=sum;
28.
29.
}
30.
</script>
31.
<form action=
"page.cgi"
method=
"post"
name=
"form1"
>
32.
<input type=
"text"
name=
"text1"
id=
"text1"
value=
"2"
/>Checkbox 1
33.
<input name=
"chk1"
type=
"checkbox"
id=
"chk1"
value=
"Y"
OnClick=
"JavaScript:return fnccheck();"
>
34.
<br>
35.
<input type=
"text"
name=
"text2"
id=
"text2"
value=
"4"
/>
36.
Checkbox 2
37.
<input name=
"chk2"
type=
"checkbox"
id=
"chk2"
value=
"Y"
OnClick=
"JavaScript:return fnccheck();"
>
38.
<br>
39.
<input type=
"text"
name=
"total"
id=
"total"
/>
40.
</form>
41.
</body>
42.
</html>