List box which is populated by selecting from another

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
davidtube
Forum Commoner
Posts: 79
Joined: Sun Mar 25, 2007 8:42 pm

List box which is populated by selecting from another

Post by davidtube »

I've got a database table with categories and subcategories. I want users to select a category from a listbox then a second listbox will be populated with all the related subcategories. How do I go about this? I know how to populate the first listbox from the table.
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Post by califdon »

Do you need to get the data for the second dropdown from the database? If so, you need to make another query and either return a new html page (ugly) or use Ajax technique to return dynamic data for the existing page. In either case, you'll be writing Javascript code.
User avatar
CoderGoblin
DevNet Resident
Posts: 1425
Joined: Tue Mar 16, 2004 10:03 am
Location: Aachen, Germany

Post by CoderGoblin »

Dynamic/Chained Selects using Ajax Prototype/JQuery has a couple of solutions although you will have to figure out the database retrieval.
davidtube
Forum Commoner
Posts: 79
Joined: Sun Mar 25, 2007 8:42 pm

Post by davidtube »

Thanks. I've got no AJAX experience but it's time I learned so that's ok. Thanks for pointing me in the right direction.
Post Reply