<script> function add_row() { var table = document.getElementById("myTable"); count_rows = table.getElementsByTagName("tr").length; var row = table.insertRow(count_rows); var cell1 = row.insertCell(0); var cell2 = row.insertCell(1); var cell3 = row.insertCell(2); var cell4 = row.insertCell(3); var cell5 = row.insertCell(4); var cell6 = row.insertCell(5); cell1.innerHTML = count_rows; cell2.innerHTML = "<input type='text' name='mat_name[]' size='20px' value=''>"; cell3.innerHTML = "<input type='text' name='amount[]' id='amount' value='' size='4px' onblur='calAmount();'>"; cell4.innerHTML = "<input type='text' name='unit[]' size='4px' value=''>"; cell5.innerHTML = "<input type='text' name='price_unit[]' id='price_unit' value='' size='4px' onblur='calAmount();'>"; cell6.innerHTML = "<input type='text' name='total_price[]' id='tt' size='4px'>"; } function del_row(){ var table = document.getElementById("myTable"); count_rows = table.getElementsByTagName("tr").length; document.getElementById("myTable").deleteRow(count_rows-1); } function calAmount() { var amt; var ppu; var total_price; amt=parseFloat(document.p.amount.value); ppu=parseFloat(document.p.price_unit.value); total_price =amt*ppu; document.p.tt.value=total_price; } </script>
<script> function add_row() { var table = document.getElementById("myTable"); count_rows = table.getElementsByTagName("tr").length; var row = table.insertRow(count_rows); var cell1 = row.insertCell(0); var cell2 = row.insertCell(1); var cell3 = row.insertCell(2); var cell4 = row.insertCell(3); var cell5 = row.insertCell(4); var cell6 = row.insertCell(5); cell1.innerHTML = count_rows; cell2.innerHTML = "<input type='text' name='mat_name["+count_rows+"]' size='20px' value=''>"; cell3.innerHTML = "<input type='text' name='amount["+count_rows+"]' id='amount' value='' size='4px' onblur='calAmount("+count_rows+");'>"; cell4.innerHTML = "<input type='text' name='unit["+count_rows+"]' size='4px' value=''>"; cell5.innerHTML = "<input type='text' name='price_unit["+count_rows+"]' id='price_unit' value='' size='4px' onblur='calAmount("+count_rows+");'>"; cell6.innerHTML = "<input type='text' name='total_price["+count_rows+"]' id='tt' size='4px'>"; } function del_row(){ var table = document.getElementById("myTable"); count_rows = table.getElementsByTagName("tr").length; document.getElementById("myTable").deleteRow(count_rows-1); } function calAmount(count_rows) { var amt; var ppu; var total_price; amt=parseFloat(document.p.amount[count_rows].value); ppu=parseFloat(document.p.price_unit[count_rows].value); if(amt.value !="" && ppu.value !=""){ total_price =amt*ppu; document.p.tt[count_rows].value=total_price; } } </script>
<input type="button" value="+" onclick="add_row();"> <input type="button" value="-" onclick="del_row();"> <table id=myTable> </table> <script> function add_row() { var table = document.getElementById("myTable"); count_rows = table.getElementsByTagName("tr").length; var row = table.insertRow(count_rows); var cell1 = row.insertCell(0); var cell2 = row.insertCell(1); var cell3 = row.insertCell(2); var cell4 = row.insertCell(3); var cell5 = row.insertCell(4); var cell6 = row.insertCell(5); cell1.innerHTML = count_rows; cell2.innerHTML = "<input type='text' name='mat_name["+count_rows+"]' size='20px' value=''>"; cell3.innerHTML = "<input type='text' name='amount["+count_rows+"]' id='amount["+count_rows+"]' value='' size='4px' onblur='calAmount("+count_rows+");'>"; cell4.innerHTML = "<input type='text' name='unit["+count_rows+"]' size='4px' value=''>"; cell5.innerHTML = "<input type='text' name='price_unit["+count_rows+"]' id='price_unit["+count_rows+"]' value='' size='4px' onblur='calAmount("+count_rows+");'>"; cell6.innerHTML = "<input type='text' name='total_price["+count_rows+"]' id='tt["+count_rows+"]' size='4px'>"; } function del_row(){ var table = document.getElementById("myTable"); count_rows = table.getElementsByTagName("tr").length; document.getElementById("myTable").deleteRow(count_rows-1); } function calAmount(count_rows) { var amt; var ppu; var total_price; if(document.getElementById("amount["+count_rows+"]").value !="" && document.getElementById("price_unit["+count_rows+"]").value !=""){ amt=parseFloat(document.getElementById("amount["+count_rows+"]").value); ppu=parseFloat(document.getElementById("price_unit["+count_rows+"]").value); total_price =amt*ppu; document.getElementById("tt["+count_rows+"]").value=total_price; } } </script>
<script> function add_row() { var table = document.getElementById("myTable"); count_rows = table.getElementsByTagName("tr").length; var row = table.insertRow(count_rows); var cell1 = row.insertCell(0); var cell2 = row.insertCell(1); var cell3 = row.insertCell(2); var cell4 = row.insertCell(3); var cell5 = row.insertCell(4); var cell6 = row.insertCell(5); cell1.innerHTML = count_rows; cell2.innerHTML = "<input type='text' name='mat_name["+count_rows+"]' size='20px' value=''>"; cell3.innerHTML = "<input type='text' name='amount["+count_rows+"]' id='amount["+count_rows+"]' size='4px' value='' onblur='calAmount("+count_rows+");'>"; cell4.innerHTML = "<?php $u=mysql_query("SELECT * FROM unit")or die(mysql_error()); echo "<select name='unit[]'>"; while(list($mat_unit_id,$mat_unit_name)= mysql_fetch_row($u)){ if($mat_unit_id==$mat_unit_name){ echo "<option value='$mat_unit_id' selected='selected'>$mat_unit_name</option>"; }else{ echo "<option value='$mat_unit_id'>$mat_unit_name</option>"; } } echo "</select>"; ?>"; cell5.innerHTML = "<input type='text' name='price_unit["+count_rows+"]' id='price_unit["+count_rows+"]' value='' size='4px' onblur='calAmount("+count_rows+");'>"; cell6.innerHTML = "<input type='text' name='total_price["+count_rows+"]' id='tt["+count_rows+"]' size='4px'>"; } function del_row(){ var table = document.getElementById("myTable"); count_rows = table.getElementsByTagName("tr").length; document.getElementById("myTable").deleteRow(count_rows-1); } function calAmount(count_rows) { var amt; var ppu; var total_price; //amt=parseFloat(document.p.amount.value); //ppu=parseFloat(document.p.price_unit.value); if(document.getElementById("amount["+count_rows+"]").value !="" && document.getElementById("price_unit["+count_rows+"]").value !=""){ amt=parseFloat(document.getElementById("amount["+count_rows+"]").value); ppu=parseFloat(document.getElementById("price_unit["+count_rows+"]").value); total_price =amt*ppu; document.getElementById("tt["+count_rows+"]").value=total_price; } } </script>
<script> function add_row() { var table = document.getElementById("myTable"); count_rows = table.getElementsByTagName("tr").length; var row = table.insertRow(count_rows); var cell1 = row.insertCell(0); var cell2 = row.insertCell(1); var cell3 = row.insertCell(2); var cell4 = row.insertCell(3); var cell5 = row.insertCell(4); var cell6 = row.insertCell(5); cell1.innerHTML = count_rows; cell2.innerHTML = "<input type='text' name='mat_name["+count_rows+"]' size='20px' value=''>"; cell3.innerHTML = "<input type='text' name='amount["+count_rows+"]' id='amount["+count_rows+"]' size='4px' value='' onblur='calAmount("+count_rows+");'>"; cell4.innerHTML = "<select name='unit["+count_rows+"]'><?php $u=mysql_query("SELECT * FROM unit")or die(mysql_error()); while(list($mat_unit_id,$mat_unit_name)= mysql_fetch_row($u)){ if($mat_unit_id==$mat_unit_name){ echo "<option value='$mat_unit_id' selected='selected'>$mat_unit_name</option>"; }else{ echo "<option value='$mat_unit_id'>$mat_unit_name</option>"; } } ?>+"</select>"; cell5.innerHTML = "<input type='text' name='price_unit["+count_rows+"]' id='price_unit["+count_rows+"]' value='' size='4px' onblur='calAmount("+count_rows+");'>"; cell6.innerHTML = "<input type='text' name='total_price["+count_rows+"]' id='tt["+count_rows+"]' size='4px'>"; } function del_row(){ var table = document.getElementById("myTable"); count_rows = table.getElementsByTagName("tr").length; document.getElementById("myTable").deleteRow(count_rows-1); } function calAmount(count_rows) { var amt; var ppu; var total_price; //amt=parseFloat(document.p.amount.value); //ppu=parseFloat(document.p.price_unit.value); if(document.getElementById("amount["+count_rows+"]").value !="" && document.getElementById("price_unit["+count_rows+"]").value !=""){ amt=parseFloat(document.getElementById("amount["+count_rows+"]").value); ppu=parseFloat(document.getElementById("price_unit["+count_rows+"]").value); total_price =amt*ppu; document.getElementById("tt["+count_rows+"]").value=total_price; } } </script>
<script> function add_row() { var table = document.getElementById("myTable"); count_rows = table.getElementsByTagName("tr").length; var row = table.insertRow(count_rows); var cell1 = row.insertCell(0); var cell2 = row.insertCell(1); var cell3 = row.insertCell(2); var cell4 = row.insertCell(3); var cell5 = row.insertCell(4); var cell6 = row.insertCell(5); cell1.innerHTML = count_rows; cell2.innerHTML = "<input type='text' name='mat_name["+count_rows+"]' size='20px' value=''>"; cell3.innerHTML = "<input type='text' name='amount["+count_rows+"]' id='amount["+count_rows+"]' size='4px' value='' onblur='calAmount("+count_rows+");'>"; cell4.innerHTML = "<select name='unit["+count_rows+"]'><?php $u=mysql_query("SELECT * FROM unit")or die(mysql_error()); while(list($mat_unit_id,$mat_unit_name)= mysql_fetch_row($u)){ if($mat_unit_id==$mat_unit_name){ echo "<option value='$mat_unit_id' selected='selected'>$mat_unit_name</option>"; }else{ echo "<option value='$mat_unit_id'>$mat_unit_name</option>"; } } ?>"+"</select>"; cell5.innerHTML = "<input type='text' name='price_unit["+count_rows+"]' id='price_unit["+count_rows+"]' value='' size='4px' onblur='calAmount("+count_rows+");'>"; cell6.innerHTML = "<input type='text' name='total_price["+count_rows+"]' id='tt["+count_rows+"]' size='4px'>"; } function del_row(){ var table = document.getElementById("myTable"); count_rows = table.getElementsByTagName("tr").length; document.getElementById("myTable").deleteRow(count_rows-1); } function calAmount(count_rows) { var amt; var ppu; var total_price; if(document.getElementById("amount["+count_rows+"]").value !="" && document.getElementById("price_unit["+count_rows+"]").value !=""){ amt=parseFloat(document.getElementById("amount["+count_rows+"]").value); ppu=parseFloat(document.getElementById("price_unit["+count_rows+"]").value); total_price =amt*ppu; document.getElementById("tt["+count_rows+"]").value=total_price; } } </script>
เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง