Checkbox not being checked when running function

Posted by Rudiger on Stack Overflow See other posts from Stack Overflow or by Rudiger
Published on 2010-03-08T05:31:08Z Indexed on 2010/03/08 5:36 UTC
Read the original article Hit count: 757

Filed under:
|
|

I have a checkbox that when it is clicked it submits the form to the server to store the detail. All works fine except that after the form is submitted I update a div to say submitted but the checkbox isn't ticked. The page isn't refreshed of course and upon page refresh it is ticked.

I thought I might be able to check the box myself as I'm using jQuery but I have a lot of these checkboxes each with a dynamic name so I'm not sure how I would call them. I thought something like:

$('input[name=("favourite" + id)]').attr('checked', true);

might work but no luck. If I don't call the function on the checkbox being ticked the checkbox behaves normally.

Thanks for anything that could help.

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about checkbox