if ($("checkbox[name='my_checkbox']:checked").length == 0) {
    //None are checked
}
else {
    //At least one is checked
}


Sir Rawlins wrote:
> Hello Guys,
>
> Fairly noobish here so hoping to learn a little something from this
> challenge.
>
> I have a form which contains a bunch of different checkboxes (all the
> same name) and a bunch of different button elements. I want to by
> default have these buttons disabled unless at least one checkbox is
> checked, if no checkboxes are checked then they need to be disabled.
>
> <input type="checkbox" name="my_checkbox" />
> <input type="checkbox" name="my_checkbox" />
> <input type="checkbox" name="my_checkbox" />
> <input type="checkbox" name="my_checkbox" />
> <input type="checkbox" name="my_checkbox" />
>
> <button type="button">Click me to do something</button>
> <button type="button">Click me to do something else</button>
> <button type="button">Click me to do something cool</button>
> <button type="button">Click me to do nothing</button>
>
> If this were just a single checkbox then I could figure this out
> without too much hassle but I'm unsure as to how I should be checking
> is any of the boxes are checked, presumably we can do some sort of
> array count for instances of it or something? who knows?
>
> I'd appreciate your thoughts on this guys.
>
> Robert

Reply via email to