<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv=Content-Type content="text/html; charset=tis-620"> <title>Untitled Document</title> <? include "config.in.php"; mysql_query("SET NAMES TIS620"); $sql="SELECT * FROM teacher WHERE Teacher_ID >0 ORDER BY teacher.Teacher_ID ASC"; $query=mysql_query($sql); $numrows=mysql_num_rows($query); ?> <script> function check() for(var i = 1; i <=<?=$numrows;?> i++){ if(document.forms.member.Teacher_ID[i].checked==false){ alert("กรุณาอาจารย์ ด้วยครับ"); return false; } } </script> <style type="text/css"> <!-- .style1 {color: #4DA0C6} --> </style> </head> <body> <form name="member" method="post" action="" onsubmit="return check();"> <label> <? //$sql="select * from teacher order by Teacher_ID ASC where Teacher_ID < 0 "; for($a=1;$a<=$numrows;$a++){ $rs=mysql_fetch_array($query); ?> <input name="Teacher_ID" type="radio" class="style1" value= "<?=$rs['Teacher_ID'];?>" /> <span class="style1"> <?=$rs['Teacher_Prefix'];?> <?=$rs['Teacher_Fname'];?> </span></label> <span class="style1"> <?=$rs['Teacher_Lname'];?> </span><br /> <br /> <label></label> <? } ?> <label> <input type="submit" name="Submit" value="Submit"/> </label> </form> </html>
function check() { for(var i = 1; i <=<?php echo $numrows; ?>; i++){ eval("if(document.forms.member.Teacher_ID["+i+"].checked==false){alert('กรุณาอาจารย์ ด้วยครับ');return false;}"); } return true; }
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <script type="text/javascript" src="jquery-1.4.4.min.js"></script> <script type="text/javascript"> $(document).ready(function(){ $('#myform').submit(function(){ if($(":checked").size() < 1) { alert('เลือกอาจารย์หน่อย'); return false; }else{ return true; } }); }); </script> </head> <body> <?php $cbx = array( 1=>"อาจารย์กอ", 2=>"อาจารย์ขอ", 3=>"อาจารย์คอ", 4=>"อาจารย์งอ", 5=>"อาจารย์จอ", ); ?> <form id="myform" method="post"> <?php foreach($cbx as $id=>$name){ echo '<input type="radio" name="teacher" id="teacher' . $id . '" /><label for="teacher' . $id . '">' . $name . '</label><br />'; } ?> <input type="submit" value="submit" /> <input type="reset" value="reset" /> </form> </body> </html>
เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง