我有两个收音机盒。 一个被称为“锁定”&其他为“解锁”
锁定&解锁按钮如下:
<label>
<input name="radiogroup_<?php echo $RepeatSelectionCounter_2; ?>" type="radio" value="Y" id="locked" <?php if (!(strcmp($row_MultipleLOPStatus['LOPStatus'],"Y"))) {echo "checked=\"checked\"";} ?> > Lock
</label>
<label>
<input <?php if (!(strcmp($row_MultipleLOPStatus['LOPStatus'],"N"))) {echo "checked=\"checked\"";} ?> name="radiogroup_<?php echo $RepeatSelectionCounter_2; ?>" type="radio" value="N" id="unlocked">
Unlock
</label>
我有结帐框,如下所示:
<label class="css-input switch switch-success">
<input type="checkbox" name="completed" value="5" id="completed" <?php if (!(strcmp($row_EditJobStatus['Status'],5))) {echo "checked=\"checked\"";} ?> ><span></span> Choose if you completed your job!
现在点击复选框(id =已完成)我想要'已解锁'(收音机)进行检查&amp; “锁定”(收音机)即使手动检查也要取消选中。
当我选中'已完成'复选框时,“解锁”(收音机)会被检查。但是“锁定”的收音机并没有得到控制。可以在'锁定'时检查。
我有以下脚本:
<script>
var completed = $("input[type='checkbox'][value='5']");
var unlocked = $("input[type='radio'][value='N']");
completed.on('change', function(){
unlocked.prop('checked',this.checked);
});
</script>
<script>
$(document).on("click", "input[id='unlocked']", function(){
thisRadio = $(this);
if (thisRadio.hasClass("imChecked")) {
thisRadio.removeClass("imChecked");
thisRadio.prop('checked', false);
} else {
thisRadio.prop('checked', true);
thisRadio.addClass("imChecked");
};
})
</script>
<script>
$(document).on("click", "input[id='locked']", function(){
thisRadio = $(this);
if (thisRadio.hasClass("imChecked")) {
thisRadio.removeClass("imChecked");
thisRadio.prop('checked', false);
} else {
thisRadio.prop('checked', true);
thisRadio.addClass("imChecked");
};
})
</script>