<%@ page language="java" import="java.util.*" pageEncoding="gb2312"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<script>
//全选
//全部取消
function selectAll(formName,cbName){
alert("hhhhh");
var o=document.forms(formName).item(cbName);
if(o.length){
for(i=0;i<0.length;i++){
focument.forms(formName).item(cbName)[i].checked=true;
}
}
else{
o.checked=true;
}
}
</script>
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'chooseAllCheckbox.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>
<form name="form1">
<input type="checkbox" name="interest" value="1">旅游<br>
<input type="checkbox" name="interes1" value="2">音乐<br>
<input type="checkbox" name="interest" value="3">运动<br>
<input type="button" value="全选" onclick="selectAll(form1,interest)">
</form>
</body>
</html>
------解决方案--------------------
<input type="button" value="全选" onclick="selectAll(form1,interest)">
这样传参可以????
好像不可以吧。
<input type="button" value="全选" onclick="selectAll()">、
- JScript code
function selectAll(){//在这里获取var formName =...var cbName = ... alert("hhhhh"); var o=document.forms(formName).item(cbName); if(o.length){ for(i=0;i<0.length;i++){ focument.forms(formName).item(cbName)[i].checked=true; } } else{ o.checked=true; } } </script>