Is there anyway I could control the selected item, and put it on the top of the current selection box. I know for the first and last 4 item, it may not be able to show on the top of the select box. But if I have hundreds of record, I want the selected item to show on the top if they not the first or last 4. And I am not interested in the items before the selected item either. Could anyone help? Thanks.
I have the testing code below.
<HTML><HEAD><SCRIPT type=”text/javascript”>
function searchSel() {
var input=document.getElementById(‘txt’).value.toLowerCase();
var list=document.getElementById(‘items’).options;
for(var i=0;i<list.length;i++) {
if(list[i].value.indexOf(input)==0)
{
list[i].selected=true;
break;
}
}
}
</SCRIPT></HEAD><BODY>
<FORM id=”myform” name=”myform”>
Search <input type=”text” id=”txt” onkeyup=”searchSel()”><br />
<SELECT id=”items” size=”5″>
<OPTION value=”abcd”>abcd
<OPTION value=”abdc”>abdc
<OPTION value=”abcd”>abcd
<OPTION value=”bacd”>bacd
<OPTION value=”badc”>badc
<OPTION value=”bcda”>bcda
<OPTION value=”bcdc”>bcdc
<OPTION value=”cdef”>cdef
<OPTION value=”cdfe”>cdfe
<OPTION value=”cfde”>cfde
<OPTION value=”cfed”>cfed
<OPTION value=”defg”>defg
<OPTION value=”degf”>degf
<OPTION value=”degg”>degg
<OPTION value=”deff”>deff
</SELECT>
</FORM></BODY></HTML>