a=document.getElementById("form1").getElementsByTagName("input")
for(i=0;i<a.length;i++)
  if(a[i].type=="checkbox")
    a[i].checked=false我是新手,刚学,不知道这样行不行

解决方案 »

  1.   


    <!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=gb2312" />
    <title>js</title>
    <script>
    function ck()
    {
    var k=document.getElementsByName("a").length;
    var a=document.getElementById("All").checked;
    for (var i=0;i<k;i++)document.form1.a[i].checked=a;
    }
    </script>
    </head>
    <body>
    <form id="form1" name="form1" method="post" action="3.asp">
    <input name="All" type="checkbox" value="All" onclick="ck();"/><li><input type="checkbox" name="a" value="a0" />0</li><br />
    <li><input type="checkbox" name="a" value="a1" />1</li><br />
    <li><input type="checkbox" name="a" value="a2" />2</li><br />
    <li><input type="checkbox" name="a" value="a3" />3</li><br />
    <li><input type="checkbox" name="a" value="a4" />4</li><br />
    <li><input type="checkbox" name="a" value="a5" />5</li><br />
    <li><input type="checkbox" name="a" value="a6" />6</li><br /><input type="submit" name="Submit" value="OK" onclick="ck()"/>
    </form>
    </body>
    </html>
      

  2.   

    <%
    a = Trim(Request.Form("a"))
    if a <> "" then
        b = split(a, ",")
        for i = 0 to ubound(b)
            response.write("choice value list:" & b(i) & "<br />")
        next
    end if
    %>
    <!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=gb2312" />
    <title>js</title>
    <script>
    function ck()
    {
    var checkboxs = document.getElementsByName("a");
    var checked = document.getElementById("all").checked
    for (var i = 0; i < checkboxs.length; i++)
    checkboxs[i].checked = checked;
    }
    </script>
    </head>
    <body>
    <form id="form1" name="form1" method="post" action="3.asp">
    <input id="all" type="checkbox" value="All" onclick="ck();"/>
    <%for i=0 to 9 %>
        <li><input type="checkbox" name="a" value="a<%=i%>" /><%=i%></li><br />
    <%next%>
    <input type="submit" name="Submit" value="OK"/>
    </form>
    </body>
    </html>