small medium large xlarge

Generic-user-small
07 Dec 2007, 01:50
Cris Paltenghe (4 posts)

Suppose you have two drop down selects that are related. You want the contents of the second one to be dependent on the selection made in the first one, but don’t want the user to have to hit SUBMIT to make the contents populate. I suppose that this is an AJAX thing, but wasn’t sure how to do it.

Any suggestions?

Generic-user-small
04 Jan 2008, 16:16
Adrian Short (1 post)

You’d need to do this with Javascript, not necessarily AJAX. If you could preload all the options for the second menu when the page is first loaded then you could just use JS to decide which options to present in the second menu. This approach would be useful if the overall page weight with all the options were relatively light.

If you had a greater number of options you could trigger an AJAX call to generate the second menu using a div replacement when the first has been changed.

The general pattern is called “chained selectors” so if you search for that you’ll probably find a lot of examples.

http://www.ajax-tutorials.com/tutorial-list/resource/Chained_select_boxes/

You must be logged in to comment