Hi,
I'm new to javascript & trying to achieve a feature for Select Box to incorporate the feature of a textbox also. Like my select box has two events attached, onchange=smeFunction(var1.value) & onkeyup=findValue(this).
- function findValue(sel) {
-
-
var temp = true;
-
var k = String.fromCharCode(event.keyCode);
-
fnd += k;
-
for (var i=0; i<sel.options.length; i++) {
-
if (fnd.toUpperCase() == sel.options[i].text.substring(0, fnd.length).toUpperCase())
-
{
-
sel.options[i].selected = true;
-
temp = false;
-
break;
-
}
-
}
-
if(temp) {
-
fnd = "";
-
fnd += k;
-
}
-
return true;
-
}
Now the problem is findValue() is returning correct value in the select box, but the screen changes are reflected wrongly based on onchange event. Like if i have ATR, CLA, etc as options & i type CLA, the select box shows CLA but the screen shows the changes wrt ATR, which belongs to the last character presssed 'A' in 'CLA'. Kindly tell whether the function itself is wrong or i can do something to improve it.
Please help, i am in great need,
Thanks in advance.....