03.
<head>
04.
<meta http-equiv=
"Content-Type"
content=
"text/html; charset=utf-8"
/>
05.
<title>Untitled Document</title>
06.
</head>
07.
08.
<body>
09.
10.
<script type=
"text/javascript"
>
11.
$(document).ready(
function
(){
12.
13.
var
rows = 1;
14.
$(
"#createRows"
).click(
function
(){
15.
var
tr =
"<tr>"
;
16.
tr = tr +
"<td width='94' align='center'>ชื่อวัตถุดิบ</td><td><div align='center'><select name='mtr_id"
+rows+
"' id='mtr_id"
+rows+
"'><option value=''>----เลือก----</option><?php $sql='SELECT * FROM material ORDER BY material.mtr_id DESC';$query=mysql_query($sql);while($result=mysql_fetch_array($query)){?><option value='<?php echo $result['mtr_id']?>'><?php echo $result['mtr_name']?></option><?php } ?></select></div></td>"
;
17.
tr = tr +
"<td width='149' align='center'>ปริมมาณ</td><td><div align='center'><input type='text' name='Volume"
+rows+
"' id='Volume"
+rows+
"'></div></td>"
;
18.
tr = tr +
"</tr>"
;
19.
$(
'#myTable > tbody:last'
).append(tr);
20.
21.
$(
'#hdnCount'
).val(rows);
22.
rows = rows + 1;
23.
24.
$(document).ready(
function
() {
25.
$(
'#s1'
).change(
function
() {
26.
var
val1 = $(this).find(
":selected"
).val();
27.
var
val2 = $(
'#s2'
).find(
":selected"
).val();
28.
if
(val1 == val2){
29.
alert(
'ซ้ำ1'
);
30.
31.
}
32.
});
33.
});
34.
35.
$(
"#deleteRows"
).click(
function
(){
36.
if
($(
"#myTable tr"
).length != 1) {
37.
$(
"#myTable tr:last"
).remove();
38.
}
39.
});
40.
41.
$(
"#clearRows"
).click(
function
(){
42.
rows = 1;
43.
$(
'#hdnCount'
).val(rows);
44.
$(
'#myTable > tbody:last'
).
empty
();
45.
});
46.
47.
});
48.
</script>
49.
50.
<form action=
"save.php?pro_id=<?php echo $_GET['pro_id']?>"
method=
"POST"
enctype=
"multipart/form-data"
name=
"add"
class
=
"form-horizontal"
id=
"add"
onSubmit=
"return Check_txt()"
>
51.
<h4>เพิ่มข้อมูลวัตถุดิบสินค้า
52.
<?php
$query_product
= sprintf(
"SELECT* FROM product where pro_id='"
.
$_GET
['pro_id
']."'
");
53.
$product
= mysql_query(
$query_product
)
or
die
(mysql_error());
54.
$row_product
= mysql_fetch_assoc(
$product
);
55.
echo
"("
.
$row_product
[
'pro_name'
] .
")"
;
56.
?></h4>
57.
<table width=
"600"
border=
"0"
id=
"myTable"
>
58.
<!-- head table -->
59.
<thead>
60.
<tr>
61.
<td width=
"94"
align=
"center"
>ชื่อวัตถุดิบ </td>
62.
<td width=
"194"
align=
"center"
>
63.
<select name=
"mtr_id"
id=
"mtr_id"
>
64.
<option value=
''
>----เลือก----</option>
65.
<?php
66.
$sql
=
"SELECT * FROM `material` ORDER BY `material`.`mtr_id` DESC"
;
67.
$query
=mysql_query(
$sql
);
68.
while
(
$result
=mysql_fetch_array(
$query
)){
69.
?>
70.
<option value=
"<?php echo $result['mtr_id']?>"
><?php
echo
$result
[
'mtr_name'
]?> </option>
71.
<?php } ?>
72.
</select></td>
73.
<td width=
"149"
align=
"center"
>ปริมมาณ</td>
74.
<td width=
"145"
align=
"center"
><input type=
'text'
name=
'Volume'
id=
'Volume'
onKeyUp=
"if(isNaN(this.value)){ alert('กรุณากรอกเฉพาะตัวเลขเท่านั้น'); this.value='';}"
></td>
75.
</tr>
76.
</thead>
77.
<!-- body dynamic rows -->
78.
<tbody></tbody>
79.
</table>
80.
<br />
81.
<input type=
"button"
id=
"createRows"
value=
"เพิ่มวัตถุดิบ"
class
=
"btn btn-primary"
>
82.
<input type=
"button"
id=
"deleteRows"
value=
"ลบ"
class
=
"btn btn-primary"
>
83.
<input type=
"button"
id=
"clearRows"
value=
"ล้าง"
class
=
"btn btn-primary"
>
84.
<center>
85.
<br>
86.
<input type=
"hidden"
id=
"hdnCount"
name=
"hdnCount"
>
87.
<input type=
"submit"
value=
"บันทึก"
class
=
"btn btn-primary"
>
88.
</form>
89.
90.
</body>
91.
</html>