<br /> <label> <input type="radio" name="toon" value="yes" onclick="show_table_toon(this.value);"> เคยได้รับทุการศึกษา </label> <label> <input type="radio" name="toon" value="no" onclick="show_table_toon(this.value);"> ไม่เคยได้รับทุการศึกษา </label> <br /> <br /> <script language="javascript"> function show_table_toon(id) { if(id == "yes") { // ถ้าเลือก radio button 1 ให้โชว์ table 1 และ ซ่อน table 2 document.getElementById("myTbl","myBt").style.display = ""; } else if(id == "no") { // ถ้าเลือก radio button 2 ให้โชว์ table 2 และ ซ่อน table 1 document.getElementById("myTbl","myBt").style.display = "none"; } } </script> <script type ="text/javascript"> $(function(){ $("#addRow").click(function(){ var NR =""; NR="<tr>"; NR+="<td width=\"60\">"; NR+="<input type=\"text\" name=\"Scholarships_year\" id=\"Scholarships_year\" size=\"10\" />"; NR+="</td>"; NR+="<td width=\"120\">"; NR+="<input type=\"text\" name=\"Scholarships_name\" id=\"Scholarships_name\" size=\"20\" />"; NR+="</td>"; NR+="<td width=\"120\">"; NR+="<input type=\"text\" name=\"Scholarships_kind\" id=\"Scholarships_kind\" size=\"20\" />"; NR+="</td>"; NR+="<td width=\"120\">"; NR+="<input type=\"text\" name=\"Scholarships_money\" id=\"Scholarships_money\" size=\"20\" />"; NR+="</td>"; NR+="</tr>"; //$("#myTbl").append($("#firstTr").clone()); $("#myTbl").append($(NR)); }); $("#removeRow").click(function(){ if($("#myTbl tr").size()>2){ $("#myTbl tr:last").remove(); }else{ alert("ต้องมีรายการข้อมูลอย่างน้อย 1 รายการ"); } }); }); </script> <table id="myTbl" width="70" border="1" style="display:"> <tr> <td align="center">ปีการศึกษา</td> <td align="center">ชื่อทุน</td> <td align="center">ประเภท</td> <td align="center">จำนวนเงิน</td> </tr> <tr id="firstTr"> <td width="10"><input name="Scholarships_year" type="text" id="Scholarships_year" size="10" /></td> <td width="20"><input name="Scholarships_name" type="text" id="Scholarships_name" size="20" /></td> <td width="20"><input name="Scholarships_kind" type="text" id="Scholarships_kind" size="20" /></td> <td width="20"><input name="Scholarships_money" type="text" id="Scholarships_money" size="20" /></td> </tr> </table> <p> <button id="addRow" type="button">+</button> <button id="removeRow" type="button">-</button> </p>
<label><input type="radio" name="toon" value="yes" checked/> เคยได้รับทุการศึกษา </label> <label><input type="radio" name="toon" value="no"/> ไม่เคยได้รับทุการศึกษา </label> <div id="DivTable"> <table id="myTbl" width="70" border="1" style="display:"> <tr> <td align="center">ปีการศึกษา</td> <td align="center">ชื่อทุน</td> <td align="center">ประเภท</td> <td align="center">จำนวนเงิน</td> </tr> <tr id="firstTr"> <td width="10"><input name="Scholarships_year" type="text" id="Scholarships_year" size="10" /></td> <td width="20"><input name="Scholarships_name" type="text" id="Scholarships_name" size="20" /></td> <td width="20"><input name="Scholarships_kind" type="text" id="Scholarships_kind" size="20" /></td> <td width="20"><input name="Scholarships_money" type="text" id="Scholarships_money" size="20" /></td> </tr> </table> <p> <button id="addRow" type="button">+</button> <button id="removeRow" type="button">-</button> </p> </div>
$(function(){ $("#addRow").click(function(){ var NR =""; NR="<tr>"; NR+="<td width=\"60\">"; NR+="<input type=\"text\" name=\"Scholarships_year\" id=\"Scholarships_year\" size=\"10\" />"; NR+="</td>"; NR+="<td width=\"120\">"; NR+="<input type=\"text\" name=\"Scholarships_name\" id=\"Scholarships_name\" size=\"20\" />"; NR+="</td>"; NR+="<td width=\"120\">"; NR+="<input type=\"text\" name=\"Scholarships_kind\" id=\"Scholarships_kind\" size=\"20\" />"; NR+="</td>"; NR+="<td width=\"120\">"; NR+="<input type=\"text\" name=\"Scholarships_money\" id=\"Scholarships_money\" size=\"20\" />"; NR+="</td>"; NR+="</tr>"; //$("#myTbl").append($("#firstTr").clone()); $("#myTbl").append($(NR)); }); $("#removeRow").click(function(){ if($("#myTbl tr").size()>2){ $("#myTbl tr:last").remove(); }else{ alert("ต้องมีรายการข้อมูลอย่างน้อย 1 รายการ"); } }); $('input[name="toon"]').click(function(){ var Ck = $(this).val(); if(Ck=="no"){ $('#DivTable').hide(); }else{ $('#DivTable').show(); } }); });
เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง