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
Just consider the situation like :
here MAle radio button is checked . I want check box Reading and playing S开发者_如何学Chould be automatically checked < Default or >
Suppose Female checked - Make up and dressing
I want to check automatically
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
精彩评论