0

我的复选框提交有问题。我知道当我们要提交多值复选框时,我们必须在里面输入名称,例如:ccd_pos[]。但现在它不起作用,因为我有一个 javascript 验证,在选中复选框 1 后启用了复选框 2、3、4 的功能。您可以在下面看到我的代码:

Javascript代码

if (theForm.ccd_chk.checked)
{
    theForm.ccd_pos [0].className = 'part';
    theForm.ccd_pos [1].className = 'part';
    theForm.ccd_pos [2].className = 'part';

    theForm.ccd_pos [0].disabled  = false;
    theForm.ccd_pos [0].checked  = false;
    theForm.ccd_pos [1].disabled  = false;
    theForm.ccd_pos [1].checked  = false;
    theForm.ccd_pos [2].disabled  = false;
    theForm.ccd_pos [2].checked  = false;
}
else
{
    theForm.ccd_pos [0].disabled  = true;
    theForm.ccd_pos [1].disabled  = true;
    theForm.ccd_pos [2].disabled  = true;
}

HTML 复选框

<input type="checkbox" name="ccd_chk" value="yes" class="part" onclick="ActionCcdCheck (this.form);" onkeypress="FocusChange (this.form, 5, 4);"/>
<input type="checkbox" name="ccd_pos" value="front" class="part" onkeypress="FocusChange (this.form, 6, 3);"/> Front
<input type="checkbox" name="ccd_pos" value="back" class="part" onkeypress="FocusChange (this.form, 7, 2);"/> Back
<input type="checkbox" name="ccd_pos" value="fb" class="part" onkeypress="FocusChange (this.form, 8, 1);"/> FB

所以现在我的问题是如何使复选框保持功能和复选框的值在我提交时可以结合起来。

谢谢。

4

2 回答 2

0

您需要使用 Jquery 来运行文档.....这里是代码.. 我做了一些更改....

 <script type="text/javascript"        src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript">
    $(document).ready(function(){
$('#ccd_chk').click(function(){
    if (theForm.ccd_chk.checked)
    {
        theForm.ccd_pos [0].disabled  = false;
        theForm.ccd_pos [0].checked  = false;
        theForm.ccd_pos [1].disabled  = false;
        theForm.ccd_pos [1].checked  = false;
        theForm.ccd_pos [2].disabled  = false;
        theForm.ccd_pos [2].checked  = false;
    } else {
        theForm.ccd_pos [0].disabled  = true;
        theForm.ccd_pos [1].disabled  = true;
        theForm.ccd_pos [2].disabled  = true;
    }
});
});
</script>

前后FB

于 2013-05-25T05:06:36.413 回答
0
Hers is the HTML part.....   
 <body>
 <form id="theForm" name="theForm">
 <input type="checkbox" name="ccd_chk" value="yes" onclick="ActionCcdCheck (this.form);"        onkeypress="FocusChange (this.form, 5, 4);" id="ccd_chk"/>
  <input type="checkbox" name="ccd_pos" value="front" onkeypress="FocusChange (this.form, 6, 3);" disabled="disabled"/> Front
 <input type="checkbox" name="ccd_pos" value="back" onkeypress="FocusChange (this.form, 7,   2);" disabled="disabled"/> Back
 <input type="checkbox" name="ccd_pos" value="fb" onkeypress="FocusChange (this.form, 8, 1);" disabled="disabled"/> FB
</form>
</body>
</html>
于 2013-05-25T05:11:39.943 回答