var c = document.getElementsByName("chktest");
for(i=0;i<c.length;i++)
{
   if(c[i].checked == true )
   {
        v  = c[i].value;
        break;
   }
}alert(v);

解决方案 »

  1.   

    <form name="form1">
    <%do while not rs.EOF%>
    <input type=checkbox name=chktest value=<%=rs.Fields("ID")%>>
    <%rs.movenext
    loop%>
    </form>
    ------------------
    <script>
    fnGetValue(){
        var objchk = document.form1.chktest;
        for(i=0;i<objchk.length;i++){
            if(objchk[i].checked == true ){
                 alert (objchk[i].value);
            }
        }
    }
    </script>
    ----------------------------
    代码没经过测试。大概就是这样。自己修改一下。
      

  2.   

    <html>
    <head>
    <script language="javascript">
    function checkall()
    {
    for(var i=0;i<document.form1.elements.length;i++)
    {
    e=document.form1.elements[i];
    if(e.checked)
    alert(e.value)
    }
    }
    </script>
    </head>
    <body bgcolor="pink">
    <BR>
    <form name="form1">
    <input type="checkbox" name="checkbox1" value="1">1
    <input type="checkbox" name="checkbox1" value="2">2
    <input type="checkbox" name="checkbox1" value="3">3
    <input type="checkbox" name="checkbox1" value="4">4
    <input type="checkbox" name="checkbox1" value="5">5
    <BR><BR>
    <input type="button" value="button" onclick="checkall()">
    </form>
    </body>
    </html>