Page 1 of 1

Dependant drop-down menus

Posted: Fri Aug 03, 2007 4:32 am
by Wardy7
I have a MYSQL database that contains car makes in one column and all the different models from than manufacturer in the columns next to it.
e.g.
Ford - Fiesta - Focus - Galaxy - GT - Mustang - Puma - etc.

Anyway, what I want to create is a drop down menu of the Manufacturers and when a manufacturer is selected another dropdown menu automatically gets populated with all the models of car for that manufacturer.

Is anyone able to help? I have searched a bit on the internet but can't find anything that is of any help! :(

Cheers
Wardy

***edit***Just thought this may have been better in the Database section?!

Posted: Fri Aug 03, 2007 8:33 am
by Chalks
I think you'll probably want to take a gander at this ajax tutorial... I just read it myself :). I don't think you'll be able to create the second menu without at least a small amount of time to query the database and whatnot, but... it shouldn't take too long.

Alternatively, you could pre-create all the possible menus in your page, and set them all to invisible, then onmouseover set visible menu X, and onmouseout hide menu X. That would probably be simpler unless you have a huge number of possible menus. You can easily do that using html, css and javascript. The problem with doing that is if your end user had javascript disabled, they probably wouldn't be able to see the menus. There are workarounds for that however. The easiest being whenever you click on a link, go to a page that includes the submenu already visible.

Posted: Sat Aug 04, 2007 2:50 pm
by CoderGoblin
Javascript and Dynamic Select Boxes is probably a more meaningful tutorial on these boards if I understand you requirements correctly. If this doesn't suit what you need the phrase you may want to use when searching is "Dynamic Select Boxes" or "Chained Selects".

Posted: Sat Aug 04, 2007 10:35 pm
by RobertGonzalez
Moved to client side.

This could be done with no Javascript, but it would require a post to the server. Otherwise, it would require javascript (this exact question has been asked here before and answered here before so you might want to search a little bit around. Yes, the exact question. Yes, car makers, then car models.).

Be forewarned that users that don't have javascript enabled will still need a means by which to use your dropdowns.