1 <script type="text/javascript"> 2 function checkAll(name) { 3 var el = document.getElementsByTagName(‘input‘); 4 var len = el.length; 5 for (var i = 0; i < len; i++) { 6 if ((el[i].type == "checkbox") && (el[i].name == name)) { 7 el[i].checked = true; 8 } 9 } 10 } 11 function clearAll(name) { 12 var el = document.getElementsByTagName(‘input‘); 13 var len = el.length; 14 for (var i = 0; i < len; i++) { 15 if ((el[i].type == "checkbox") && (el[i].name == name)) { 16 el[i].checked = false; 17 } 18 } 19 } 20 </script>
1 <form action="result.jsp"> 2 <input type="checkbox" name="test1" value="" 3 onclick="if(this.checked==true) { checkAll(‘test‘); } else { clearAll(‘test‘); }" /> 4 字母全选开关 <input type="checkbox" name="test" value="a" /> a <input 5 type="checkbox" name="test" value="b" /> b <input type="checkbox" 6 name="test" value="c" /> c <input type="checkbox" name="test" 7 value="d" /> d <input type="submit" value="submit" /> 8 </form>
1 <% 2 String list[] = request.getParameterValues("test"); 3 for(String s:list){ 4 %> 5 <%=s %> 6 <%} %>
时间: 2024-11-25 21:30:55