YUI Library Examples: AutoComplete Control: Query a JavaScript Array for In-memory Data

AutoComplete Control: Query a JavaScript Array for In-memory Data

There are two AutoComplete widgets on this page that each point to a different DS_JSArray DataSource instance. Driving each DataSource is a local JavaScript array of strings: statesArray and areaCodesArray. By pointing to arrays that are already loaded into memory the widget is very fast to return data.

Enabling the prehighlightClassName feature provides supplemental visual feedback for mouse events on results in the container.

The formatResult method of the second AutoComplete instance has been enhanced to display two data fields in the container, and the forceSelection property has been enabled to prevent the user from typing in a free-form selection.

Find a state:

Find an area code

Sample Code

CSS:

Markup:

JavaScript:

Copyright © 2007 Yahoo! Inc. All rights reserved.

Privacy Policy - Terms of Service - Copyright Policy - Job Openings