joedunn
asked on
Drop Down Box Selection Populates Another Drop Down Box
The effect I want to create is really simple, however, doing it is not, at least for me.
I have a form on a page. When a selection in combo box 1 is made it populates combo box number 2 then 3 then 4.
Like this...
Box 1 - Country
Box 2 - State
Box 3 - City
Box 4 - Zip Code
So for this example let assume I make the following choices:
Box 1: United States (All countries would be displayed in Box 1)
Box 2: Idaho (All 50 US States would have been available
Box 3: Boise (A list of cities that I wanted for Idaho would be here)
Box 4: 83705 (a List of available zip codes for Boise, ID, USA)
I know I have to supply the lists for each box, that is easy, I have the data.
#1. How can I do this?
#2. Is it possible to do this via a connection to a DB where each table in the DB contains information for a different field? That would be the best but I'll take whatever I can get help with.
Thanks
I have a form on a page. When a selection in combo box 1 is made it populates combo box number 2 then 3 then 4.
Like this...
Box 1 - Country
Box 2 - State
Box 3 - City
Box 4 - Zip Code
So for this example let assume I make the following choices:
Box 1: United States (All countries would be displayed in Box 1)
Box 2: Idaho (All 50 US States would have been available
Box 3: Boise (A list of cities that I wanted for Idaho would be here)
Box 4: 83705 (a List of available zip codes for Boise, ID, USA)
I know I have to supply the lists for each box, that is easy, I have the data.
#1. How can I do this?
#2. Is it possible to do this via a connection to a DB where each table in the DB contains information for a different field? That would be the best but I'll take whatever I can get help with.
Thanks
ASKER
How can I do this using Ajax?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
The page would load, write php to generate a second selection box based on what was submitted for the first.
If you want to do this without reloading, you would need to use an AJAX solution. Onchange of the select element, send the value to the server, have the server generate the code (using PHP if you wish) for the second drop down box that will be returned to the page via AJAX, and use javascript to replace the second drop down list with the new list.