making two drop down one based on another

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
rami
Forum Contributor
Posts: 217
Joined: Thu Sep 15, 2005 8:55 am

making two drop down one based on another

Post 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
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Post 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.
(#10850)
User avatar
bokehman
Forum Regular
Posts: 509
Joined: Wed May 11, 2005 2:33 am
Location: Alicante (Spain)

Post by bokehman »

Just in case you want to Google it, the proper terminology is a "chained select".
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

CoderGoblin has a tutorial (hint hint) posted about doing this via Javascript.
rami
Forum Contributor
Posts: 217
Joined: Thu Sep 15, 2005 8:55 am

Post 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
Post Reply