I have a bit of an odd/unique situation, where I am currently looking for a way to 're-populate' checkboxes on my page.
First some background on how the page/app works.
1.) state1: You get simple search form. Enter in first or last or state, etc., hit submit. It queries a DB and posts back to the SAME Page (?mode=results).
Inside of a MAIN container DIV, I loop through the returned records, and create (echo) a TABLE with a certain tabular layout to parse the values from each record/row (name, date, ID#, etc).
If I have 5 records returned from DB, I loop through and create 5 tables right after each other, populating each with the unique data from the record/row.
In each one of these tables I create, along with the data from the DB record/row. I also create/add in several check boxes.
Using some jQuery and on $(document).ready, I listend for the onClick event for all these checkboxes. So when clicked, I grab some data from the checkbox, as well as some parent info, and do the following:
a.) I create/add another element to the stage
b.) Make an Ajax call to an external .php script, so that I can update the SESSION with my array I have build (collecting all the user checks/input)
I build the array in JS/jQuery and use the Ajax call to get this data into my PHP session (anyone knows a way to NOT use this external .php script to update the SESSION var, let me know please!)
So to re-cap so far: There is no "FORM" (tags), just check boxes in multiple tables. There really is no 1-button (submit) event that POSTS all the checkbox data anywhere at one time. Each time a checkbox is clicked (or un-clicked), I update my SESSION array. That if/when a user IS ready to 'check out' (for lack of better term) (leave the page and go to another page), the SESSION data/array is 'current' and the data is ready to be used on any following pages.
so far everything posted above works just fine.
The question I have is: If the user wants to go BACK to this MAIN PAGE with all the checkboxes, what nice, simple/elegant solutions do I have to re-populate all these checkboxes?
I'm thinking the only approach I have is the check and see if this SESSION array exists when main page loads (meaning it's a re-visit, not the first time), and try to loop through this array and somehow target elements on my stage to find the correct table, then the checkbox ID?
Usually use jQuery to walk the DOM - not PHP? And what about toggling the checkbox with PHP?
Is there a nice way to do this?