in reply to Dynamic Drop down in CGI
There are two approaches you could take. Both will start with a select element containing the list of cities. Then you either…
- Have a simple text input in which the user can enter the data free form.
- Have a submit button and let the user go to a new page which gives them the next set of choices.
If you went with the free form text input, remove it using JS.
Generate something to indicate that more options will be available once the first select has items picked. A disabled select element for instance.
When the first select has an item picked, populate the second one and stop it being disabled. You will need to get the data from somewhere. This could be included in the page at load time, or requested from the server (using an Ajax technique) on demand. The first option will be more responsible, but will have a heavier inital load. The decision should be based on the size of your database.