What you did looks fine if it only runs one on page load. Which means
if you check/uncheck after the fact, nothing else will happen.
If you want it to work dynamically, you have to attach an event to the
checkbox. Maybe something like:

$("input[name^=REQ_ACCT_LAB_]").click(function() {
            if ($(this).is(":checked"))
            {
                $("input[name=MY_CHK]").attr("checked","checked");
            }
            else
            {
                $("input[name=MY_CHK]").attr("checked","");
            }
});

On Mar 2, 11:36 am, Jael <jae...@yahoo.com> wrote:
> Hi all,
>
> I am new to this forum and hope someone can direct me a little..
>
> I have a checkbox that needs to be checked/unchecked under the following
> rules..
>
> if any checkboxes with id like "REQ_ACCT_LAB_" are checked, then check it
> if all of the checkboxes with id like "REQ_ACCT_LAB_" are unchecked, then
> uncheck it.
>
> Is there a better way of doing this?
>
> heres my code:
>
>             if ($("input[name^=REQ_ACCT_LAB_]").is(":checked"))
>             {
>                 $("input[name=MY_CHK]").attr("checked","checked");
>             }
>             else
>             {
>                 $("input[name=MY_CHK]").attr("checked","");
>             }
>
> Thanks!
> --
> View this message in 
> context:http://www.nabble.com/toggle-a-checkbox----tp22233470s27240p22233470....
> Sent from the jQuery General Discussion mailing list archive at Nabble.com.

Reply via email to