我想用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 请问改如何写,谢谢大家
我用以下方法传递:
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 请问改如何写,谢谢大家
<!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>
参考下
document.location.href= 'Loginaction.jsp?id= ' + document.getElementById('GetValue').checked ? 1 : 0;
}
document.location.href= 'Loginaction.jsp?id= ' + document.getElementById('CheckBox1').checked ? 1 : 0;
}
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>