This worked. Then I tried to adjust it so that it sits on option[0] if the string typed doesn't match a value but now all it ever does is go to option[0].
Here's what I mean. In this example if the user types the string "123" in the text box the the drop box changes it's selected index to 1 etc.
The function:
Code: Select all
function updateDrop(el1,el2) {
for(i=1; i<el2.options.length; i++) {
if (el1.value == el2.optionsїi].value) {
el2.options.selectedIndex = i
} else {
el2.options.selectedIndex = 0
}
}
}Code: Select all
<form action="demo" method="post" name="demo">
<input type="text" id="text1" name="text1" onKeyup="updateDrop(this,document.getElementById('drop1'))">
<br>
<select name="drop1" id="drop1">
<option value="">Numbers</option>
<option value="123" selected>123</option>
<option value="123456">123456</option>
<option value="45678">45678</option>
<option value="5623">5623</option>
</select>
</form>Any ideas?
Thanks