01.
<html>
02.
<head>
03.
<title>ThaiCreate.Com Tutorial</title>
04.
</head>
05.
<body>
06.
<script language=
"javascript"
>
07.
function
fncCal()
08.
{
09.
var
tot = 0;
10.
var
sum = 0;
11.
for
(i=1;i<=document.form1.hdnLine.value;i++)
12.
{
13.
tot = parseInt(eval(
"document.form1.txtVol1_"
+i+
".value"
)) + parseInt(eval(
"document.form1.txtVol2_"
+i+
".value"
))
14.
eval(
"document.form1.txtVol3_"
+i+
".value="
+tot);
15.
sum = tot + tot;
16.
document.form1.txtSum.value=sum;
17.
}
18.
}
19.
</script>
20.
<form action=
"page.cgi"
method=
"post"
name=
"form1"
>
21.
Input 1 <input name=
"txtVol[]"
id=
"txtVol1_1"
type=
"text"
> <input name=
"txtVol[]"
id=
"txtVol2_1"
type=
"text"
> = <input name=
"txtVol[]"
id=
"txtVol3_1"
type=
"text"
><br>
22.
Input 2 <input name=
"txtVol[]"
id=
"txtVol1_2"
type=
"text"
> <input name=
"txtVol[]"
id=
"txtVol2_2"
type=
"text"
> = <input name=
"txtVol[]"
id=
"txtVol3_2"
type=
"text"
><br>
23.
Input 3 <input name=
"txtVol[]"
id=
"txtVol1_3"
type=
"text"
> <input name=
"txtVol[]"
id=
"txtVol2_3"
type=
"text"
> = <input name=
"txtVol[]"
id=
"txtVol3_3"
type=
"text"
><br>
24.
Input 4 <input name=
"txtVol[]"
id=
"txtVol1_4"
type=
"text"
> <input name=
"txtVol[]"
id=
"txtVol2_4"
type=
"text"
> = <input name=
"txtVol[]"
id=
"txtVol3_4"
type=
"text"
><br>
25.
Input 5 <input name=
"txtVol[]"
id=
"txtVol1_5"
type=
"text"
> <input name=
"txtVol[]"
id=
"txtVol2_5"
type=
"text"
> = <input name=
"txtVol[]"
id=
"txtVol3_5"
type=
"text"
><br>
26.
<input type=
"hidden"
name=
"hdnLine"
value=
"5"
>
27.
28.
Summary : <input name=
"txtSum"
id=
"txtSim"
type=
"text"
><br>
29.
30.
<input name=
"btnCal"
type=
"button"
value=
"Cal"
OnClick=
"JavaScript:fncCal();"
>
31.
</form>
32.
</body>
33.
</html>