<td align="center"> <input name="quntity<?php echo $i;?>" type="text" value="<? echo $row1['qty'];?>" size="3" onKeyUp="fncSum();"/></td> <td align="center"><input name="unit<?php echo $i;?>" type="text" value="" size="10" /></td> <td align="center"><input name="discount<?php echo $i;?>" type="text" size="10" value=""/></td> <td align="center"><input name="amount<?php echo $i;?>" type="text" size="10" value="" /></td> <td align="center"> <a href="delete_poprocess.php?ref1=<? echo $row1['id_po'];?> & ref2=<? echo $row1['id_ref'];?>" class="style48" OnClick="return chkdel();"><img src="image/b_drop.png" width="16" height="16" /></a></td> </tr> <? $m++; } ?> <tr> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td colspan="2" align="right">ภาษีมูลค่าเพิ่ม</td> <td align="center"><input name="vat" type="text" size="10"/></td> <td align="left" bordercolor="#FF0000">บาท</td> </tr> <tr> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td colspan="2" align="right">ยอดสุทธิ</td> <td align="center"><span class="style38"> <label> <input type="text" name="totalsum" id="totalsum" size="10" onKeyUp="if(this.value*1!=this.value) this.value='' ;"/> </label></span></td> <td align="left" bordercolor="#FF0000">บาท</td>
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>test</title> <style> .table { border: 1px solid #ccc; border-collapse: collapse; width: 100%; } .table td, .table th { border: 1px solid #ccc; padding: 5px; } </style> </head> <body> <table class="table products-table"> <tr> <td>...</td> <td>Quantity</td> <td>Unit</td> <td>Discount</td> <td>Amount</td> </tr> <tr> <td></td> <td><input type="number" name="quantity" id="quantity[1]" value="1" step="1" onkeyup="calculateTotal(1);" onchange="calculateTotal(1);"></td> <td><input type="number" name="unit" id="unit[1]" value="12.50" step="any" readonly=""></td> <td><input type="number" name="discount" id="discount[1]" value="3.50" step="any" onkeyup="calculateTotal(1);" onchange="calculateTotal(1);"></td> <td><input type="number" name="amount" id="amount[1]" class="amount" value="9" step="any" readonly=""></td> </tr> <tr> <td></td> <td><input type="number" name="quantity" id="quantity[2]" value="2" step="1" onkeyup="calculateTotal(2);" onchange="calculateTotal(2);"></td> <td><input type="number" name="unit" id="unit[2]" value="7" step="any" readonly=""></td> <td><input type="number" name="discount" id="discount[2]" value="1.50" step="any" onkeyup="calculateTotal(2);" onchange="calculateTotal(2);"></td> <td><input type="number" name="amount" id="amount[2]" class="amount" value="15.50" step="any" readonly=""></td> </tr> </table> <hr> <div> Total: <input type="number" name="total" id="total" value="24.50" step="any" readonly=""> </div> <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script> <script> $(function() { }); function calculateTotal(arrkey) { quantity = $('#quantity\\['+arrkey+'\\]').val(); unit = $('#unit\\['+arrkey+'\\]').val(); discount = $('#discount\\['+arrkey+'\\]').val(); // verify number if (isNaN(quantity)) { quantity = 1; } if (isNaN(unit)) { alert('Unit is not a number and cannot continue calculation!'); return false; } if (isNaN(discount)) { discount = 0; } // find amount amount = ((parseInt(quantity)*parseFloat(unit))-parseFloat(discount)); $('#amount\\['+arrkey+'\\]').val(amount); // clear junk delete quantity; delete unit; delete discount; delete amount; // find total. total = 0; $('.amount').each(function() { total = (parseFloat(total)+parseFloat($(this).val())); }); $('#total').val(total); } </script> </body> </html>
เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง