Page 1 of 1

Ajax based check boxes based on drop down value selected

Posted: Mon Jun 07, 2010 3:45 am
by Vijay T
Hi,

I am creating a module in PHP where in, based on the drop down value selected, list of its corresponding values are to be displayed in the form of check boxes and the user can select multiple check boxes and post the same to the database.

Could some one throw pointers or a sample code which would help me immensely

Re: Ajax based check boxes based on drop down value selected

Posted: Mon Jun 07, 2010 9:36 am
by Jonah Bron
Setup a database with two tables: one for the dropdown box, and one for checkboxes. Each row in the dropdown box table has an ID, and a value. Each row in the checkboxes database has an ID, a value, and a the ID of the dropdown box table row it's a child of. Then, when the user selects a item in the dropdown box, you would run some SQL like "SELECT * FROM checkboxes WHERE dropdown_id = (user selected item)".

Now, if you want to do this without loading a new page, that's Javascript (and maybe AJAX).