Page 1 of 1

making two drop down one based on another

Posted: Thu Sep 14, 2006 11:28 pm
by rami
i have table maincategory name as maincat_id ,maincat_name
then i have sub category as subcat_id,subcatname,maincat_id

what i want is two dropdown
in first the rows from main category will be displayed and in second drop based on main categoy on first rows from subcategory(of that main category) will be displayed
and then main_catid and sub_catid passed to another page

is there any way of doing it
may be not using too much of javascript(or may be less javascript)

Note: i saw one similar tutorial in this site but its too complicated and its not using mysql database

Posted: Fri Sep 15, 2006 12:41 am
by Christopher
Probably the most straightforward way would be to load all the data for both and use Javascript to build the sub-select. You could also have the main select submit the page and use PHP to create the sub-select.

Posted: Fri Sep 15, 2006 9:01 am
by bokehman
Just in case you want to Google it, the proper terminology is a "chained select".

Posted: Fri Sep 15, 2006 1:15 pm
by feyd
CoderGoblin has a tutorial (hint hint) posted about doing this via Javascript.

Posted: Fri Sep 15, 2006 1:22 pm
by rami
i was just about to post i have solved it
any way if some body need code, i can post it as well
it is small one and quite effectiive i got one site

thanks for all help