01.
<html>
02.
<head>
03.
<meta http-equiv=
"Content-Type"
content=
"text/html; charset=utf-8"
/>
04.
<title>ThaiCreate.Com PHP & MySQL Tutorial</title>
05.
06.
<script language=
"JavaScript"
type=
"text/JavaScript"
>
07.
<!--
08.
function
MM_jumpMenu(targ,selObj,restore){
09.
eval
(targ+
".location='"
+selObj.options[selObj.selectedIndex].value+
"'"
);
10.
if
(restore) selObj.selectedIndex=0;
11.
}
12.
function
fncSubmit()
13.
{
14.
for
(i=1;i<=document.form1.hdnLine.value;i++)
15.
{
16.
if
(
eval
(
"document.form1.txtCustomerID"
+i+
".value"
)==
""
)
17.
{
18.
alert(
"กรุณากรอกรหัสนักศึกษาคนที่ "
+i+
""
);
19.
eval
(
"document.form1.txtCustomerID"
+i+
".focus();"
)
20.
return
false;
21.
}
22.
23.
if
(
eval
(
"document.form1.txtName"
+i+
".value"
)==
""
)
24.
{
25.
alert(
"กรุณากรอกรหัสผ่านคนที่"
+i+
""
);
26.
eval
(
"document.form1.txtName"
+i+
".focus();"
)
27.
return
false;
28.
}
29.
30.
}
31.
document.form1.submit();
32.
33.
}
34.
</script>
35.
</head>
36.
<body>
37.
<form action=
"phpMySQLAddSave.php"
name=
"form1"
method=
"post"
onSubmit=
"JavaScript:return fncSubmit();"
>
38.
จำนวนคนที่ต้องการเพิ่ม :
39.
<select name=
"menu1"
onChange=
"MM_jumpMenu('parent',this,0)"
>
40.
<?
41.
for
(
$i
=1;
$i
<=6;
$i
++)
42.
{
43.
if
(
$_GET
[
"Line"
] ==
$i
)
44.
{
45.
$sel
=
"selected"
;
46.
}
47.
else
48.
{
49.
$sel
=
""
;
50.
}
51.
?>
52.
<option value=
"<?=$_SERVER["
PHP_SELF
"];?>?Line=<?=$i;?>"
<?=
$sel
;?>><?=
$i
;?></option>
53.
<?
54.
}
55.
?>
56.
</select>
57.
<table width=
"341"
border=
"1"
>
58.
<tr>
59.
<th width=
"142"
> <div align=
"center"
>รหัสนักศึกษา</div></th>
60.
<th width=
"122"
> <div align=
"center"
>รหัสผ่าน </div></th>
61.
<th width=
"122"
>check</th>
62.
</tr>
63.
<?
64.
$line
=
$_GET
[
"Line"
];
65.
if
(
$line
== 0){
$line
=1;}
66.
for
(
$i
=1;
$i
<=
$line
;
$i
++)
67.
{
68.
?>
69.
<tr>
70.
<td><div align=
"center"
><input type=
"text"
name=
"txtCustomerID<?=$i;?>"
id=
"txtCustomerID<?=$i;?>"
size=
"20"
></div></td>
71.
<td><input type=
"text"
name=
"txtName<?=$i;?>"
id=
"txtName<?=$i;?>"
size=
"20"
/></td>
72.
<td><div id=
"msg"
></div></td>
73.
74.
</tr>
75.
<?
76.
}
77.
?>
78.
</table>
79.
<input type=
"submit"
name=
"submit"
value=
"submit"
>
80.
<input type=
"hidden"
name=
"hdnLine"
value=
"<?=$i;?>"
>
81.
<?
echo
$line
;?>
82.
</form>
83.
</body>
84.
</html>