<input type="text" οnkeyup="autoComplete(this,$('Entity_id'),$('Entity_id'),'text',false)" size="15" name="Input" id="Input"/>
<SELECT NAME="Entity_id" id="Entity_id" >...</select>
<script>
function autoComplete(field, select_one,select_two, property, forcematch,copyflag) {
var select = select_one;
var found_one = false;
var found_two = false;
var selectedValue = null;
if(field.value.length==0) {return;}
for (var i = 0; i < select.options.length; i++) {
if (select.options[i][property].toUpperCase().indexOf(field.value.toUpperCase()) >= 0) {
found_one=true; break;
}
}
if(!found_one){
select= select_two;
for (var i = 0; i < select.options.length; i++) {
if (select.options[i][property].toUpperCase().indexOf(field.value.toUpperCase()) >= 0) {
found_two=true; break;
}
}
}
if(found_two){
selectedValue = select.options[i].value;
}
select=select_one;
if(found_two){
for(var j=0;j<select.options.length;j++){
if(select.options[j].value==selectedValue){
found_one=true;
i=j;
break;
}
}
}
if (found_one) { select_one.selectedIndex = i; }
else { select_one.selectedIndex = -1; }
if (field.createTextRange) {
if (forcematch && !found_one) {
field.value=field.value.substring(0,field.value.length-1);
return;
}
var cursorKeys ="8;46;37;38;39;40;33;34;35;36;45;";
if (cursorKeys.indexOf(event.keyCode+";") == -1) {
if (!copyflag) {
var r1 = field.createTextRange();
var oldValue = r1.text;
var newValue = found_one ? select_one.options[i][property] : oldValue;
if (newValue != field.value) {
//field.value = newValue;
var rNew = field.createTextRange();
rNew.moveStart('character', oldValue.length) ;
rNew.select();
}
}
}
}
}
</script>