<html> <head> <base href="<%=basePath%>"> <title>My JSP ‘check.jsp‘ starting page</title> <meta http-equiv="pragma" content="no-cache"> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="expires" content="0"> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="This is my page"> <!-- <link rel="stylesheet" type="text/css" href="styles.css"> --> </head> <body> <input type="checkbox" id="boxid" onclick="selAllNo()">全选/全不选 <hr> <input type="checkbox" name="love"/>篮球 <input type="checkbox" name="love"/>足球 <input type="checkbox" name="love"/>乒乓球 <input type="checkbox" name="love"/>排球 <input type="checkbox" name="love"/>保龄球 <hr> <input type="button" name="checkedAll" onclick="selAll()" value="全选"> <input type="button" name="checkedNo" onclick="selNo()" value="全不选"> <input type="button" name="checkedOther" onclick="selOther()" value="反选"> <script type="text/javascript"> function selAll(){ var loves = document.getElementsByName("love"); for(var i=0;i<loves.length;i++){ var love1 = loves[i]; love1.checked = true; } } function selNo(){ var loves = document.getElementsByName("love"); for(var i=0;i<loves.length;i++){ var love1 = loves[i]; love1.checked = false; } } function selOther(){ var loves = document.getElementsByName("love"); for(var i=0;i<loves.length;i++){ var love1 = loves[i]; if(love1.checked==true){ love1.checked = false; }else{ love1.checked = true; } } } function selAllNo(){ var boxid = document.getElementById("boxid"); if(boxid.checked==true){ selAll(); }else{ selNo(); } } </script> </body> </html>
时间: 2024-10-10 10:18:12