select one checkbox from multiple MAIN Checkboxes,disable all other MAIN boxes,n enable child checkbox
- by harshil
<input type="checkbox" id="chkMain" />
<input type="checkbox" id="chkMain1" />
<input type="checkbox" id="chkMain2" />
<input class="child" type="checkbox" id="chk1" disabled="true" />
<input class="child" type="checkbox" id="chk2" disabled="true" />
<input class="child" type="checkbox" id="chk3" disabled="true" />
<input class="child" type="checkbox" id="chk4" disabled="true" />
<input class="child" type="checkbox" id="chk5" disabled="true" />
<input class="child" type="checkbox" id="chk6" disabled="true" />
<input class="child" type="checkbox" id="chk7" disabled="true" />
$(function(){
$("input[id^=chkMain]").click ( function() {
if( !$(this).is ( ":checked" ) ){
$(".child").attr ( "disabled" , true );
}
else{
$(".child").removeAttr ( "disabled" );
}
});
});
this enables all the child boxes when either chkMain or chkMain1 or chkMain2 are checked.
what i want is: when chkMain is checked the code should disable chkMain1 and chkMain2 but enabling child boxes.
or
when chkMain1 is checked the code should disable chkMain and chkMain2 but enabling child boxes.