home / experts / javascript / column15 |
|
If you've read our previous columns, you know that we always define two variables to detect the user's browser:
Due to a bug in the Macintosh version of Navigator 4.0x, we must also define a variable to determine if the user is running that browser:
Another global variable enables you to set the size of the lookup list:
This variable determines the number of options that the user can see without having to scroll down the list. If
It is initially set to Our lookup list has two operation modes, as explained in the body of the script:
When the user enters or deletes a character in the text box, the script looks for a substring match. In other words, it searches the options in the list to see if any of them start with the entered string. If more than one substring match exists, the first matching option is selected. In both modes, if the text field becomes empty, the first option is selected. The only difference between the two modes is what happens when the text field is not empty, and no substring match is found. In Standard mode (1) the script selects the closes match from the bottom. In order to understand this mechanism, let's imagine the script did find a match for the user's string. But since it didn't really find one, it selects the option that would have appeared just before the imaginary match. When the lookup list is functioning in Explorer mode (2), the selection simply doesn't change if not substring match is found (and the box is not empty). The last global statement in our script invokes the
This function is explained in the next section of the column. |
Created: March 11, 1998
Revised: March 11, 1998
URL: http://www.webreference.com/js/column15/global.html