Sticky checkboxes driving MySQL Query on PHP Form

I need to have a form with "sticky" checkboxes that submit the form when one of the checkboxes is changed and stay checked or unchecked after the change.  When the form submits, it needs to send post the form and drive the refresh of the form data.
Who is Participating?
Chris StanyonCommented:
You're gonna need to introduce some javascript here to react to the checkboxes changing. It's then up to you to decide how you submit the form - you could do it in the traditional way, or the more modern approach, which is to send the form data back the server using an AJX request.

Doing it with an AJAX request means that your checkboxes would remain sticky as the user never navigates away from your page.

As for refreshing the form data - your AJAX request could pull in the new data and populate the form, again without ever having to navigate away from the page.

Can't really give you specific details with specific requirements, but the easiest way to implement an AJAX based for is to use the jQuery library.
Ray PaseurCommented:
This is such a common question that we have an article about it here at EE!

Please read that over and post back with any specific questions.  The part about persisting the client response in the database is really a matter of keeping a data model of the checkboxes in the database.  When the client submits the checkbox collection, you clear all of the database entries and set all of the checkboxes that are active in the request.  When the server prepares the web page, it creates all of the checkboxes, then marks "checked" any of the checkboxes that are set in the data base model.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.