<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>https://www.thaicreate.com/php/forum/078923.html - ถ้าจะเลือกข้อมูลใน check box แล้วให้ค่าที่เลือกแสดงในหน้าเดียวกัน </title> <meta name="Generator" content="EditPlus"> <meta name="Author" content="Unidentifier"> <meta name="Keywords" content=""> <meta name="Description" content=""> <meta http-equiv="Content-Type" content="text/html; charset=utf8" /> <script src="http://code.jquery.com/jquery-latest.js"></script> <style> #choose_repair{ background-color:#d2ce35; display:block; width:400px; overflow:none; border:4px solid #804000; padding:4px; padding-left:0px; } #repair_detail{ background-color:#e4f2f8; } ul{ list-style:none; padding:0px; } li{ display:inline-block; } </style> </head> <body> <form id="form2" name="form2" method="post" action="insertmem.php"> <ul> <li style="width:450px;"> <div id="choose_repair"> <input type="checkbox" name="repair_id[]" class="repair_id" value="101" rel="ห้องเครื่อง - ลูกสูบแตก" /> ห้องเครื่อง - ลูกสูบแตก<br /> <input type="checkbox" name="repair_id[]" class="repair_id" value="102" rel="ห้องเครื่อง - วาล์วรั่ว" /> ห้องเครื่อง - วาล์วรั่ว<br /> <input type="checkbox" name="repair_id[]" class="repair_id" value="201" rel="ระบบส่งกำลัง - ลูกปืนเพลาเสื่อม" /> ระบบส่งกำลัง - ลูกปืนเพลาเสื่อม<br /> <input type="checkbox" name="repair_id[]" class="repair_id" value="202" rel="ระบบส่งกำลัง - ผ้าคลัชหมด" /> ระบบส่งกำลัง - ผ้าคลัชหมด<br /> <input type="checkbox" name="repair_id[]" class="repair_id" value="301" rel="ภายนอก - รอยบุบ" /> ภายนอก - รอยบุบ<br /> <input type="checkbox" name="repair_id[]" class="repair_id" value="302" rel="ภายนอก - ซ่อมสี" /> ห้องเครื่อง - ซ่อมสี<br /> </div> </li> <li style="width:150px;"> <input type="submit" name="submitForm" value="...บันทึก..." /> </li> </ul> <table border="1" id="repair_detail"> <tr style="text-align:center;"> <td class="">No.</td><td class="" width="250">รายการ</td><td class="" width="280">รายละเอียด</td> <td class="" width="100">จำนวน</td><td class="" width="120">ราคา</td> </tr> </table> </form> <script type="text/javascript"> $("input[type=checkbox].repair_id").click(function(){ $("table#repair_detail tr#rows").remove(); var next_order=1 , description="" , newElement=""; $("input[type=checkbox].repair_id").each(function(){ if($(this).is(":checked")){ description = $(this).attr("rel"); newElement = "<tr id='rows'><td id='no'>"+next_order+"</td><td>"+description+"</td><td><input type='text' name='detail[]' size='35' /></td><td><input type='text' name='qty[]' size='10' /></td><td><input type='text' name='price[]' size='10' /></td></tr>"; $("table#repair_detail").append(newElement); next_order = parseInt(next_order)+1; } }); }); </script> </body> </html>
เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง