1,js限制checkbbox勾選個數的代碼:
<!DOCTYPE HTML "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <title>限制復選框選擇的數量-www.jbxue.com-腳本學堂</title> <script type="text/javascript" > checkedCount=0( i=0;i<myForm.course.length ;i ++(myForm.course[i].++(checkedCount>"不能選超過三門課程" </script> </head> <body> <form name="myForm" method="post" id="myForm" action="test.php"><br> <input type="checkbox" name="course[]" value="語文" onClick="return checkDate(3)">語文<br> <input type="checkbox" name="course[]" value="數學" onClick="return checkDate(3)">數學<br> <input type="checkbox" name="course[]" value="英語" onClick="return checkDate(3)">英語<br> <input type="checkbox" name="course[]" value="化學" onClick="return checkDate(3)">化學<br> <input type="checkbox" name="course[]" value="物理" onClick="return checkDate(3)">物理<br> <input type="checkbox" name="course[]" value="政治" onClick="return checkDate(3)">政治<br> <input type="submit" value="提交"> <input type="reset" value="取消"> </form> </body> </html>
<? =['course'(=0;<();++([]!="" []."<br/>"?>