Quote:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-874" /> <title>Untitled Document</title> </head> <body> <script type="text/javascript"> function doCalSum(Record, Qty, Price){ var Sum; Sum = parseInt(Qty) * parseFloat(Price); document.getElementById("hdnSum" + Record).value = Sum.toFixed(2); document.getElementById("spnSum" + Record).innerHTML = Sum.toFixed(2); doCalTotal(); } function doCalTotal(){ var Record = document.getElementById("hdnCount").value; var Total = 0; for(i=1;i<=Record;i++){ Total += parseFloat(document.getElementById("hdnSum" + i).value); } document.getElementById("spnTotal").innerHTML = Total.toFixed(2); } function digitsOnly(obj){ var regExp = /[0-9]$/; if(!regExp.test(obj.value)){ obj.value = obj.value.substring(0, obj.value.length -1); return false; } } </script> <form> <table width="100%" border="1" cellspacing="0" cellpadding="2"> <tr> <td align="center"><strong>Product</strong></td> <td width="120" align="center"><strong>Price</strong></td> <td width="120" align="center"><strong>Qty</strong></td> <td width="120" align="center"><strong>Sum</strong></td> </tr> <tr> <td>Test 1 <input type="hidden" name="hdnId1" id="hdnId1" value="1" /></td> <td align="center">100.25</td> <td align="center"><input name="txtQty1" type="text" id="txtQty1" size="15" value="1" onkeyup="digitsOnly(this);doCalSum(1, this.value, '100.25')"/></td> <td align="center"><span name="spnSum1" id="spnSum1">100.25</span> <input type="hidden" name="hdnSum1" id="hdnSum1" value="100" /></td> </tr> <tr> <td>Test 2 <input type="hidden" name="hdnId2" id="hdnId2" value="2" /></td> <td align="center">150.25</td> <td align="center"><input name="txtQty2" type="text" id="txtQty2" size="15" value="1" onkeyup="digitsOnly(this);doCalSum(2, this.value, '150.25')"/></td> <td align="center"><span name="spnSum2" id="spnSum2">150.25</span> <input type="hidden" name="hdnSum2" id="hdnSum2" value="150" /></td> </tr> <tr> <td colspan="3"><strong>Total</strong></td> <td align="center"><span name="spnTotal" id="spnTotal">250.50</span></td> </tr> </table> <input type="hidden" name="hdnCount" id="hdnCount" value="2"/> </form> </body> </html>
เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง