如果全部是form1的项目,你可以用循环来完成,先取得所有的复选框数组,再一个一个的设置,不过这样不一定方便,虽然编的时候要输入的比较多,但这样不容易出错,而且速度还要快些。当然如果你想以后也用这个方法来作,也是可以的。

解决方案 »

  1.   

    <script>
    function selectall(){
    var i;
    var es = document.form1.elements ;
    for(i=0;i<es.length;i++){
    if (es[i].type=="checkbox")
    es[i].checked=true;
    }
    }
    </script>
    <form name=form1>
    <input type=checkbox name=a value=a>
    <input type=checkbox name=b value=a>
    <input type=checkbox name=c value=a>
    <input type=button name=b value=selectall onclick=selectall()>
    </form>
      

  2.   

    or:<script>
    function selectall(){
    var i;
    var es = document.all.tags("input") ;
    for(i=0;i<es.length;i++){
    if (es[i].type=="checkbox")
    es[i].checked=true;
    }
    }
    </script>
    <form name=form1>
    <input type=checkbox name=a value=a>
    <input type=checkbox name=b value=a>
    <input type=checkbox name=c value=a>
    <input type=button name=b value=selectall onclick=selectall()>
    </form>
      

  3.   

    当你选种甬道的项时,把所选的结果放到一个数组里面,取值时把数组的内容读出就可以了。
    <input type="checkbox" name="name" value="a">
    <input type="checkbox" name="name" value="b">
    <input type="checkbox" name="name" value="c">
    ......
    如在jsp页面中:
    <%
     String[] check=request.getParameterValues("name"); 
     for(int i=0;i<check.length;i++)
      { name=check[i];
       }
    %>
      

  4.   

    <input type=checkbox name=a value=a><br>
    <input type=checkbox name=b value=a><br>
    <input type=checkbox name=a value=a><br>
    <input type=checkbox name=b value=a><br>
    <input type=checkbox name=c value=a><br><br><br>
    <input type=checkbox name=d onclick="cc(this)">全选与不全选的切换<script language=Javascript>
    function cc(tt)
    {
      var aa = document.getElementsByTagName("input");
      var bb = tt.checked; //得到那个总控的复选框的选中状态
      for (var i=0; i<aa.length; i++)
      {
         if (aa[i].type == "checkbox")
             aa[i].checked = bb;
      }
    }
    </script>
      

  5.   

    <script>
    function selectall(){
    var i;
    var es = document.all.tags("input") ;
    for(i=0;i<es.length;i++){
    if (es[i].type=="checkbox")
    es[i].checked=true;
    }
    }
    </script>
    <form name=form1>
    <input type=checkbox name=a value=a>
    <input type=checkbox name=b value=a>
    <input type=checkbox name=c value=a>
    <input type=button name=b value=selectall onclick=selectall()>
    </form>
      

  6.   

    好,如果这么热心的人越来越多,就有希望了,是吧,zsq0759 (john.zhong) ????