我想用document.location.href传递checkbox的值 选中的情况下 值为1,不选中的情况下值为0
我用以下方法传递:
function a()
{
document.location.href= 'Loginaction.jsp?id= '+document.getElementById('GetValue').value
}<input id="CheckBox1" name="GetValue" type="checkbox"   /><%
out.println("<td><a href='#' onclick='a()' >修改数据</a></td>");
 %>无论选中和不选中传递的值都是ON 请问改如何写,谢谢大家

解决方案 »

  1.   


    <!DOCTYPE HTML>
    <html>
    <head>
    <meta charset="gb2312" />
    <title></title>
    </head>
    <body>
    <input id="CheckBox1" name="GetValue" type="checkbox" />
    <a href='#' onclick='a()' >修改数据</a>
    <script>
    function a(){
    var f = 0;
    if( document.getElementById('CheckBox1').checked ){
    f = 1;
    }
    document.location.href= 'Loginaction.jsp?id='+f;
    }
    </script>
    </body>
    </html>
    参考下
      

  2.   

    function a() {
    document.location.href= 'Loginaction.jsp?id= ' + document.getElementById('GetValue').checked ? 1 : 0;
    }
      

  3.   

    function a() {
    document.location.href= 'Loginaction.jsp?id= ' + document.getElementById('CheckBox1').checked ? 1 : 0;
    }
      

  4.   

    getElementById这个取值 就把id 改成跟GetValue<script language="javascript">
    function a() {
        document.location.href= 'Loginaction.jsp?id= ' + document.getElementById('GetValue').checked ? 1 : 0;
    }
    </script>
    <input id="GetValue" name="GetValue" type="checkbox" />
    <a href='#' onclick='a()' >修改数据</a>
      

  5.   

    把值放在查询串里 就像你已get方式提交form表单那样