<? session_start(); ?> <html> <head> <title>ThaiCreate.Com Tutorial</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <style type="text/css"> <!-- .style5 {font-size: 12px } --> </style> </head> <script language="javascript"> function CreateNewRow() { var intLine = parseInt(document.form1.hdnMaxLine.value); intLine++; var theTable = document.all.tbExp var newRow = theTable.insertRow(theTable.rows.length) newRow.id = newRow.uniqueID var item1 = 1 var newCell //*** Column 1 ***// newCell = newRow.insertCell(0) newCell.id = newCell.uniqueID newCell.setAttribute("className", "css-name"); //newCell.innerHTML = "<center><INPUT TYPE=\"TEXT\" SIZE=\"5\" NAME=\"Column1_"+intLine+"\" VALUE=\""+intLine+"\"></center>" newCell.innerHTML = "<center>"+intLine+"</center>" //*** Column 2 ***// newCell = newRow.insertCell(1) newCell.id = newCell.uniqueID newCell.setAttribute("className", "css-name"); newCell.innerHTML = "<center><INPUT TYPE=\"TEXT\" SIZE=\"50\" NAME=\"Column2_"+intLine+"\" VALUE=\"\"></center>" //*** Column 3 ***// newCell = newRow.insertCell(2) newCell.id = newCell.uniqueID newCell.setAttribute("className", "css-name"); newCell.innerHTML = "<center><INPUT TYPE=\"TEXT\" SIZE=\"5\" NAME=\"Column3_"+intLine+"\" VALUE=\"\"></center>" //*** Column 4 ***// newCell = newRow.insertCell(3) newCell.id = newCell.uniqueID newCell.setAttribute("className", "css-name"); newCell.innerHTML = "<center><INPUT TYPE=\"TEXT\" SIZE=\"10\" NAME=\"Column4_"+intLine+"\" VALUE=\"\"></center>" //*** Column 5 ***// newCell = newRow.insertCell(4) newCell.id = newCell.uniqueID newCell.setAttribute("className", "css-name"); newCell.innerHTML = "<center><INPUT TYPE=\"TEXT\" SIZE=\"10\" NAME=\"Column5_"+intLine+"\" VALUE=\"\"></center>" document.form1.hdnMaxLine.value = intLine; // alert(intLine); if(intLine == 10) { alert('คุณกรอกครบ 10 รายการแล้ว'); document.getElementById('btnAdd').disabled = true ; } } function RemoveRow() { intLine = parseInt(document.form1.hdnMaxLine.value); if(parseInt(intLine) > 0) { theTable = (document.all) ? document.all.tbExp : document.getElementById("tbExp") theTableBody = theTable.tBodies[0]; theTableBody.deleteRow(intLine); document.getElementById("theTable").disabled = false; intLine--; document.form1.hdnMaxLine.value = intLine; if(intLine < 11) { document.getElementById('btnAdd').disabled = false ; } } } </script> <body> <form action="verifeproblem.php" method="post" name="form1" enctype="multipart/form-data"> <table width="100%" border="0" align="center" cellpadding="1" id="tbExp"> <tr> <td width="6%"><div align="center">ลำดับที่</div></td> <td width="29%"><div align="center">รายการ</div></td> <td width="16%"><div align="center">จำนวน</div></td> <td width="13%"><div align="center">ราคา</div></td> <td width="36%"><div align="center">ราคารวมทั้งหมด</div></td> </tr> <tr> <td> </td> <td> </td> <td> </td> <td><label> <div align="center"></div> </label></td> <td><label> <div align="center"></div> </label></td> </tr> </table> <label></label></td> </tr> <tr> <td><input type="hidden" name="hdnMaxLine" value="0"> <input name="btnAdd" type="button" id="btnAdd" value="เพิ่มรายการ" onClick="CreateNewRow();"> <input name="btnDel" type="button" id="btnDel" value="ลบรายการ" onClick="RemoveRow();"></td> </tr> <tr> <td><input type="submit" name="save" id="save" value="บันทึก"></td> </tr> </table> <p> <label></label> </p> <p> </p> </form> </body> </html> ตอนนี้มีปัญหาเรื่องการลบ textbox ครับ คือ ไม่สามารถลบเมื่อถึง textbox ที่ 8 และไม่สามารถเพิ่มต่อได้ครับ ไม่ทราบว่าผมแก้ไขโค้ดผิดตรงไหนครับ
เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง