|Subject:||Small problem, with solutions and question|
Response to: Small problem, with solutions and question
While no easy generalizable solution comes to mind, you could possibly use the onload event to invoke a function that sets up an array (the pseudo-hash tables I describe in the book would be good for this) that associates each select element with a digit--the digit is calculated by iterating through all option values and finding the longest value. Then modify the typeAhead() function (as you've done), but substituting the matching hash table value for the maximum length of the active select element (hard-coded as 2 in your example).
Hear us Roar