| Sign In/My Account | View Cart |
| Article: |
Cooking with JavaScript & DHTML | |
| Subject: | numbers as option text? | |
| Date: | 2004-01-16 09:38:16 | |
| From: | anonymous2 | |
|
Response to: numbers as option text?
|
||
|
correction: numeric type ahead does not work when i use the numeric keypad on the keyboard.
|
||
Showing messages 1 through 4 of 4.
delay property of the typeAheadInfo object constructor function.
It's also possible that with so many options, the scripting bogs down with repeated fetches of the options for each keystroke. Perhaps rework the code to perform the retrieval just once (at onload time) and preserve the list in a global variable for faster subsequent retrievals.
delay property of the typeAheadInfo object constructor function.
But there is an simple relationship between the two sets, and the way to account for it is to insert a small corrector statement in the typeAhead() function after the line that reads: var charCode = evt.keyCode. Here's the new code to add:
// correct for NumPad digits
if (charCode >= 96 && charCode <=105) {
charCode = charCode - 48;
}
That should let the numeric keypad (and top row numbers) work with option values consisting of numerals.
In hindsight, I'd word some of the comments in the article code differently to prevent giving the impression the event is working with character codes.