我有两组复选框,当我单击第一组复选框时,应取消选中第二组复选框。但是当我两次单击第一个复选框时,第二个复选框未选中。这是我的 javascript 代码
<script>
function uncheck0(){
for(var ii=1; ii<=3; ii++){
if(document.getElementById("q6_"+ii).checked==true){
document.getElementById("q6_"+ii).checked=false;
}
}
}
function uncheck(id, from, to){
for(var ii=from; ii<=to; ii++){
if(document.getElementById(id+ii).checked==true){
document.getElementById(id+ii).checked=false;
}
}
}
</script>
这是我的html 代码,第一组有单选按钮,第二组有复选框
<p>IF YES: When will the review begin?</p>
<label for="q6"><input type="radio" class="styled" value="Within the next 12 months" name="q6[]" id="q6_1">Within the next 12 months</label>
<label for="q6"><input type="radio" class="styled" value="Within the next 24 months" name="q6[]" id="q6_2">Within the next 24 months</label>
<label for="q6"><input type="radio" class="styled" value="We are currently doing it" name="q6[]" id="q6_3">We are currently doing it</label><br>
<br>
<p>IF NO: Why Not</p>
<label onclick="uncheck('q6_',1,3);" for="q6"><input type="checkbox" class="styled" value="Lack of budget" name="q6[]" id="q6_4">Lack of budget</label>
<label onclick="uncheck('q6_',1,3);" for="q6"><input type="checkbox" class="styled" value="Lack of resource" name="q6[]" id="q6_5">Lack of resource</label>
<label onclick="uncheck('q6_',1,3);" for="q6"><input type="checkbox" class="styled" value="Do not see the need" name="q6[]" id="q6_6">Do not see the need</label>
<label onclick="uncheck('q6_',1,3);" for="q6"><input type="checkbox" class="styled" value="Lack of know how/expertise" name="q6[]" id="q6_7">Lack of know how/expertise</label>
<label onclick="uncheck('q6_',1,3);" for="q6"><input type="checkbox" class="styled" value="Complexity" name="q6[]" id="q6_8">Complexity</label>
<label onclick="uncheck('q6_',1,3);" for="q6"><input type="checkbox" class="styled" value="Contractual obligations" name="q6[]" id="q6_9">Contractual obligations</label>
<label onclick="uncheck('q6_',1,3);" for="q5"><input type="checkbox" class="styled" value="Other" name="q6[]" id="q6_10">Other </label>
<label onclick="uncheck('q6_',1,3);" for="q5a">Please state</label><input type="text" value="" id="q6a" name="q6a">
我已使用 javascript 文件“custom-form-element.js”进行复选框和单选样式