关于checkbox的js写法。
我的问题可能有些怪异。
比如 <input type=checkbox name=chk1 value=1> 1
<input type=checkbox name=chk1 value=1> 2
<input type=checkbox name=chk1 value=1> 3
<input type=checkbox name=chk1 value=1> 4
然后我在2、4上钩选中,这样的话表单会把“1,1”传给处理页面;
如果我想传 "0,1,0,1 "给处理页面,即没有钩选的,值就为0
这样一种逻辑,该如何实现?
------解决方案--------------------命名为不一样的最简单了。
------解决方案-------------------- <%
If request( "chk1 ") <> " " Then
Response.Write( "值是: "&request( "chk1 "))
End if
%>
<SCRIPT LANGUAGE= "JavaScript ">
<!--
function mysubmit()
{
if(!document.getElementById( "chk1_1 ").checked)
{
document.getElementById( "chk1_1_0 ").disabled = false;
document.getElementById( "chk1_1_0 ").checked = true;
document.getElementById( "chk1_1 ").disabled = true;
}
if(!document.getElementById( "chk1_2 ").checked)
{
document.getElementById( "chk1_2_0 ").disabled = false;
document.getElementById( "chk1_2_0 ").checked = true;
document.getElementById( "chk1_2 ").disabled = true;
}
if(!document.getElementById( "chk1_3 ").checked)
{
document.getElementById( "chk1_3_0 ").disabled = false;
document.getElementById( "chk1_3_0 ").checked = true;
document.getElementById( "chk1_3 ").disabled = true;
}
if(!document.getElementById( "chk1_4 ").checked)
{
document.getElementById( "chk1_4_0 ").disabled = false;
document.getElementById( "chk1_4_0 ").checked = true;
document.getElementById( "chk1_4 ").disabled = true;
}
document.getElementById( "Form1 ").submit();
}
//-->
</SCRIPT>
<FORM id= "Form1 " METHOD=POST ACTION= "Noname3.asp ">
<input type=checkbox name=chk1 id=chk1_1 value=1> 1
<div style= "display:none; ">
<input type=checkbox name=chk1 id=chk1_1_0 value=0 disabled>
</div>
<input type=checkbox name=chk1 id=chk1_2 value=1> 2
<div style= "display:none; ">
<input type=checkbox name=chk1 id=chk1_2_0 value=0 disabled>
</div>
<input type=checkbox name=chk1 id=chk1_3 value=1> 3
<div style= "display:none; ">
<input type=checkbox name=chk1 id=chk1_3_0 value=0 disabled>
</div>
<input type=checkbox name=chk1 id=chk1_4 value=1> 4
<div style= "display:none; ">
<input type=checkbox name=chk1 id=chk1_4_0 value=0 disabled>
</div>
<INPUT TYPE= "button " onclick= "mysubmit(); " value= "提交 "/>
</FORM>