01.
<table
class
=
"table table-bordered"
>
02.
<tr>
03.
<td colspan=
"5"
><?
echo
$process_category_name
;?></td>
04.
</tr>
05.
<tr>
06.
<td width=
"5%"
> ลำดับ</td><td width=
"55%"
>รายการสินค้า</td><td width=
"10%"
>ราคา</td><td width=
"15%"
>จำนวน</td><td width=
"15%"
>ยอดรวม</td>
07.
</tr>
08.
09.
<?php
10.
11.
$qr_x
=dbQuery(
"SELECT * FROM tbl_product where process_category_id = '$process_category_id' ORDER BY product_name ASC"
);
12.
$row
=@mysql_num_rows(
$qr_x
);
13.
$i
=0;
14.
while
(
$i
<
$row
){
15.
$rs_x
=mysql_fetch_array(
$qr_x
);
16.
$product_id
=
$rs_x
[
'product_id'
];
17.
$product_name
=
$rs_x
[
'product_name'
];
18.
$price
=
$rs_x
[
'price'
];
19.
20.
?>
21.
<tr>
22.
<td width=
"5%"
><?
echo
$i
+1;?></td><td width=
"55%"
><?
echo
$product_name
;?></td><td width=
"10%"
><?
echo
$price
;?>
23.
<input type=
"hidden"
name=
"price<?=$product_id;?>"
value=
"<? echo $price;?>"
size=
"2"
onfocus=
"startCalc<?=$product_id;?>()"
onblur=
"stopCalc<?=$product_id;?>()"
></td><td width=
"15%"
>
24.
<input type=
"number"
class
=
"form-control"
min=
"0"
name=
"num<?=$product_id;?>"
size=
"2"
onfocus=
"startCalc<?=$product_id;?>()"
onblur=
"stopCalc<?=$product_id;?>()"
></td><td width=
"15%"
>
25.
<input type=
"text"
name=
"sum_price<?=$product_id;?>"
class
=
"input-label"
size=
"2"
value=
"0"
disabled=
"disabled"
></td>
26.
</tr>
27.
<SCRIPT Language=
"JavaScript"
>
28.
function
startCalc<?=
$product_id
;?>(){
29.
interval = setInterval(
"calc<?=$product_id;?>()"
,1);
30.
}
31.
function
calc<?=
$product_id
;?>(){
32.
num<?=
$product_id
;?> = document.autoSumForm.num<?=
$product_id
;?>.value;
33.
price<?=
$product_id
;?> = document.autoSumForm.price<?=
$product_id
;?>.value;
34.
document.autoSumForm.sum_price<?=
$product_id
;?>.value = (num<?=
$product_id
;?>) * (price<?=
$product_id
;?>);
35.
36.
}
37.
function
stopCalc<?=
$product_id
;?>(){
38.
clearInterval(interval);
39.
}
40.
</SCRIPT>
41.
42.
43.
44.
<?
45.
$i
++;
46.
}
47.
?>
48.
</table>