Article:
  Cooking with JavaScript & DHTML
Subject:   Small problem, with solutions and question
Date:   2005-01-15 16:11:54
From:   dannyg1
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).


First thoughts on how I'd start to approach the problem.


Good luck and thanks for reading.


Danny