Male <input value="V1" checked="checked" name="R1" type="radio">
Female: <input name="R1" value="V2" type="radio"></p>
<input name="C1" value="ON" type="checkbox">Reading
<input name="C2" value="ON" type="checkbox">Dressing
<input name="C3" value="ON" type="checkbox">Make up
<input name="C4" value="ON" type="checkbox">Playing
请考虑以下情况:
这里检查MAle单选按钮。我想复选框阅读和播放应该自动检查&lt;默认或&gt;
假设女性检查 - 化妆和敷料
我想自动检查
答案 0 :(得分:2)
function select_radio(val){
if (val=="male"){
document.getElementById("C1").checked = true;
document.getElementById("C2").checked = true;
document.getElementById("C3").checked = false;
document.getElementById("C4").checked = false;
}
else{
document.getElementById("C3").checked = true;
document.getElementById("C4").checked = true;
document.getElementById("C1").checked = false;
document.getElementById("C2").checked = false;
}
}
Male <input value="V1" checked="checked" name="R1" type="radio" onclick="select_radio('male')">
Female: <input name="R1" value="V2" type="radio" onclick="select_radio('female')">></p>
<input name="C1" id="C1" value="ON" type="checkbox">Reading
<input name="C2" id="C2" value="ON" type="checkbox">Dressing
<input name="C3" id="C3" type="checkbox">Make up
<input name="C4" id="C4" type="checkbox">Playing