Filling chained combo boxes that depend upon each other
This recipe tries to solve a very common task that is seen in many web applications, that is, filtering contents of a combo box according to the selection made in its previous combo box.
We will create an example where the user will be presented with three select boxes—one each for country, state, and town. Selecting a country will get its states and selecting a state will get its towns. Finally, on selecting a town we will display some information related to it.
The most important point here is that there will not be any page reloads. Instead, we will use AJAX to filter the contents silently. This will create a better user experience compared to classic web application behavior where it would have required a full-page reload on each selection.
Getting ready
Create a folder named Recipe3
inside the Chapter8
directory. Now, we will require four tables in our database. Once again, open phpMyadmin, create these four tables, and fill them with...