|
Posted by Peter van Schie on 11/25/05 23:33
Nick wrote:
> What I want to do is have 2 pull down lists, for example a state pull
> down list and a city pull down list. What I would like to have done is
> when you select a state from the state pull down list then the city
> pull down list will populate with all the cities from that selected
> state. I know that is a lot of data but that is just an example. Or
> something like when you are looking up cars online they have a make
> pull down list and a model pull down list, and when you select the make
> it will populate the model pull down list with all the models from that
> make. Thank you.
>
Hi Nick,
You basically have two options:
1. Use client-side Javascript: load the data from both lists into
javascript arrays and write an onclick handler for the first selectbox,
to set the contents of the second selectbox.
You could check out
http://www.blueshoes.org/en/javascript/multilevelselector/
for example. You can use that component which works like I described.
2. Use AJAX to allow communication with the server when you click an
item in the first selectbox. You don't need to preload all data
client-side like that.
If you want to know more about this technique, read my tutorial at:
http://www.phpforums.nl/cgi-bin/forum/YaBB.pl?num=1131752404
HTH.
--
http://www.phpforums.nl
Navigation:
[Reply to this message]
|