Many forms have a select box in them that is very large, source-wise. For example, a country select box that names all the countries in the world.
In Chapter 2, Quick Tricks, I described how to load up the second select box based on the value of a first select box. In this section, I'll describe how to load up the first select box through Ajax.
In many cases, it is possible to select a default value that is correct for most visitors. For example, if I was working on an Irish website and a contact form needed the visitor's country to be entered, it would be safe to assume that Ireland should be the default, and the visitor can change it if they need to.
This allows us to do something interesting. Instead of printing out the entire list of countries into a select box, it is only necessary to print one, and to load up the full list only if the select box is actually touched by the visitor (click or focus). This is great for long forms that have many large select boxes.