onclick()事件无法访问复选框的问题
<%@ page contentType="text/html; charset=utf-8" language="java" import="java.sql.*" errorPage="" %>
<!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" />
<title>无标题文档</title>
<script language="javascript" type="text/javascript">
function checkboxSelect(checkAll){
   if(checkAll.checked==true){
      document.reg.box.checked=true;
	 return true;
   }
   return false;    
}
</script>
</head>
<body>
<form action="" method="post" name="reg">
   <table width="232" height="197">
     <tr>
       <td width="29" height="38"><label>选择</label></td>
       <td width="39">标题</td>
       <td width="37">作者</td>
       <td width="107">日期</td>
     </tr>
     <tr>
       <td height="46">
         <input type="checkbox" name="box" value="2" />
       </td>
       <td>咨询</td>
       <td>李四</td>
       <td>2004-4-8</td>
     </tr>
     <tr>
       <td height="49">
         <input type="checkbox" name="box" value="3" />
       </td>
       <td>配送</td>
       <td>王五</td>
       <td>2008-5-8</td>
     </tr>
   </table>
    <input type="checkbox" name="checkbox" value="checkbox"  onclick="checkboxSelect(this)"/>全选
    <input type="submit" name="Submit" value="删除" />
</form>
</body>
</html>
上面的jsp代码当我点击"全选"复选框时,表格中的复选框都没有选中,好像checkboxSelect()没有被调用,这个该怎么改??
------解决方案--------------------function checkboxSelect(checkAll){
 if(checkAll.checked==true||checkAll.checked=="checked"){
 var form=document.getElementsByName("box");
 for(var i=0;i<form.length;i++){
 	form[i].checked="checked";
 }    
 return true;
 }
 return false;    
}
</script>
这样试试
------解决方案--------------------onclick没问题,我试过,用下面的我试过了没问题
JScript code
function checkboxSelect(checkAll){
  if(checkAll.checked==true){
      alert(2);
     var b = document.getElementsByName("box");
     for(var i=0;i<b.length;i++){
             b[i].checked = true; 
          }
  }         
}