我的复选框提交存在问题。我知道当我们想要提交多个值复选框时,我们必须在内部命名如: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
所以现在我的问题是如何使复选框保持功能和复选框的值可以在我提交时合并。
感谢。
答案 0 :(得分: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
答案 1 :(得分: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>