Form Completion

One of the prototypical Ajax use cases is form completion, where a user enters information in a field that causes other fields on the page to change. For example, we can use Ajax to react to the value entered into a Zip Code field, as shown in Figure 2.

Figure 2. Form completion (Top: User enters an unknown Zip Code. Bottom: User enters a known Zip Code.)


When the user leaves the Zip Code textfield, we send an Ajax request to the server, passing the current value of the Zip Code field as a request parameter. We associate the Zip Code field with the event handler like this:

The zipChanged function uses Prototype to send the Ajax ...

Get AJAX and JavaServer™ Faces now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.