LyndonOHRC
Programmer
Hi, I need to set the selectedIndex of a select element based on users input in a text box.
I was hoping I read enough examples to do it myself but I guess I was dreaming.
The following code does not generate any errors, but, the selected index does not change either. Any help appreciated.
Lyndon
---People Remember about 10% of what you say ---They never forget how you made them feel. Covey
I was hoping I read enough examples to do it myself but I guess I was dreaming.
The following code does not generate any errors, but, the selected index does not change either. Any help appreciated.
Code:
var strUserEntered=document.getElementById('LicenseType').value.trim();
sel=document.getElementById('LicenseTypeOther');
var elementArrayLength = sel.length;
for (i=0;i<elementArrayLength;i++) {
if (sel[i].value==strUserEntered) {
sel.selectedIndex = i;
}
}
Lyndon
---People Remember about 10% of what you say ---They never forget how you made them feel. Covey