SCENARIO: I have a select box that displays 10 items and when I hit a letter key and the box has to scroll down, the highlighted item appears at the bottom of the box.

QUESTION: How can I get the highlighted item to appear at the top of the select box?

JS IN USE: This is the script I am currently using with onkeypress. It allows searching in the selectbox in the following manner: The first letter you select, the box will find the first entry that starts with that letter (as is the default). The second letter you select, the box will find the entry that has the first letter you already select and the second letter in the entry with the second letter you entered. So if you type in 'C' first then 'E', it will highlight the first entry that starts with 'CE' and so on.

// Global Variables
var i = 0;
var success = false;
var elem = event.srcElement;
var tLowElemText = '';
// Get the unicode char of the keypress
var eCode = event.keyCode;
// Check if it's a vaid ASCII Character
if (eCode == 27){
tString = '';
elem.selectedIndex = 0;
else if ( (eCode > 31) && (eCode < 122))
// Convert the Code to the corresponding character and add to searchstring
tString += String.fromCharCode(eCode);
// ... and perform the search starting from the top element in the listbox
while (success == false)
i = 0;
// Convert everything to lowercase; allows an easy comparison
var tLowString = tString.toLowerCase();
// Compose the regexp searchstring ...
var rExpr = eval("/^" + tLowString + "/");
while ((i < elem.length)&& (success == false) )
tLowElemText = elem.options[i].text.toLowerCase();
// success: Position the listbox on the (first) found element
if ( != -1)
elem.selectedIndex = i;

success = true;
else {
i++; }
} // while i < elem.length
// if nothing is found in the entire list, the last character of the searstring is
// removed to allow typing the correct 'next' character
if (success == false) {
tString = tString.substr(0, tString.length-1);
} // while success = false

window.event.returnValue = false;
window.event.cancelBubble = true;