Reputation: 2055
I have a few checkboxes, labelled MON, TUE, WED, through to SUN. I want a checkbox that is labelled ALL, that would uncheck and disable the other 7 checkboxes. I'm using JQuery, but I can't find documentation for this particular issue.
Here's the HTML:
<div class="feed-info-input-lbl-set">
<div class="feed-info-label lbl-company-role">Delivery</div>
<div class="checkbox-and-value">
<div class="feed-info-input input-delivery-day" >SUN
<br />
<input id="chk-sun" class="chk-ctrl" type="checkbox" name="delivery-day" value="sunday" />
</div>
<div class="feed-info-input input-delivery-day" >MON
<br />
<input id="chk-mon" class="chk-conn" type="checkbox" name="delivery-day" value="monday" />
</div>
<div class="feed-info-input input-delivery-day" >TUE
...ETC
</div> <!-- End Checkboxes -->
Anybody have any information on how to achieve this?
Thanks.
Upvotes: 1
Views: 1111
Reputation: 31033
you can try something like
$("#ALL").change(function(){
if($(this).is(":checked")){
$(":checkbox").not(this).attr("disabled","disabled").removeAttr("checked");
}else{
$(":checkbox").not(this).removeAttr("disabled");
}
});
Upvotes: 3
Reputation: 2111
Should be fairly simple. Use jquery selectors to identify your checkboxes (can't get more precise without a code sample) and then call .prop("checked", false) followed by .attr('disabled', 'disabled') on the lot of them.
...if that doesn't solve your problem, perhaps you could be a bit clearer about what you're having difficulty with?
Upvotes: 1