jQuery check checkbox via MySQL query
I have a form with a group of checkboxes. Each checkbox in the group is named "foo[]". The user clicks one or more check boxes then clicks next. The values of the checkboxes are then stored in a MySQL database via PHP. No big deal.
Suppose the user wants to go back and change his/her selections. I'd like them to see what boxes they checked previously.
I'm trying to figure out a good solution to this. Since I need each checkbox to be named "foo[]" for PHP purposes, I can't give them a unique name. I tried giving them each a unique class then doing something like:
$('.bar').attr('checked','checked');
But that didn't do anything. And even if it did, I'd have to have a separate line for each possible checkbox value of which there could be over a dozen. Not a very graceful solution.
(Side note: I'm actually using a UI buttonset, if that makes a difference. I don't see why it would though....)
Something tells me I'm over-thinking this and that there is a good solution. Maybe someone out there knows what it is... :-)