<select id='cityselect'>
<option>
Москва
</option>
<option>
Санкт-Петербург
</option>
<option>
Нижний Новгород
</option>
<option>
Новосибирск
</option>
<option>
Красноярск
</option>
<option>
Хабаровск
</option>
<option>
Хабара
</option>
</select>
<input type='text' id='cityvalue' />
<script type='text/javascript'>
var elems = document.getElementById("cityselect").options;
var similar = function (A, B) {
for (var i = 0; i < B.length; i++)
if (A.charAt(i) != B.charAt(i)) break;
return i;
};
document.getElementById("cityvalue").onkeypress = function (event) {
var max = 0;
for (var i = 0; i < elems.length; i++) {
var A = elems[i].innerHTML.replace(/^\s+|\s+$/g, "").toLowerCase(),
B = (this.value + String.fromCharCode(event.keyCode)).toLowerCase();
if (similar(A, B) > max)
elems[i].selected = "selected", max = similar(A, B);
}
};
</script>