Lookup Lists: Final Thoughts - Doc JavaScript | WebReference

Lookup Lists: Final Thoughts - Doc JavaScript

A Final Word

In this column we introduced a useful technique for providing a long list of sites in a JavaScript menu. Rather than having to scroll through the list to find the desired site, the user can enter the first few characters and the script automatically selects the matching option. This column focused on forms and event handlers. We explained several algorithms for the lookup list.

The script must be able to detect when the user presses a key, so it only works on fourth-generation browsers. However, the script works on both Navigator 4.0x and Internet Explorer 4.0x, and gracefully downgrades for older browsers by:

In this column you learned:

  1. How to define the basic global variables for the script.
  2. How to initialize the lookup list.
  3. How to print the list's HTML code via JavaScript.
  4. How to update the text field when the user manually changes the selection.
  5. How to select a matching option.

For your convenience, you may also view the entire code.


Created: March 11, 1998
Revised: March 11, 1998

URL: http://www.webreference.com/js/column15/final.html