By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,969 Members | 1,767 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,969 IT Pros & Developers. It's quick & easy.

Javascript : Select Box not functioning properly

P: 4
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).

Expand|Select|Wrap|Line Numbers
  1. function findValue(sel) {
  2.  
  3.     var temp = true;
  4.     var k = String.fromCharCode(event.keyCode);
  5.     fnd += k;
  6.     for (var i=0; i<sel.options.length; i++) {
  7.     if (fnd.toUpperCase() == sel.options[i].text.substring(0, fnd.length).toUpperCase())
  8.                 {
  9.        sel.options[i].selected = true;
  10.        temp = false;
  11.       break;
  12.     }
  13.     }
  14.     if(temp) {
  15.                        fnd = "";
  16.                        fnd += k;
  17.                 }
  18.         return true;
  19.     }
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.....
Jun 12 '07 #1
Share this Question
Share on Google+
2 Replies


iam_clint
Expert 100+
P: 1,208
the events are on the text box or the select box?
Jun 12 '07 #2

P: 4
the events are on the text box or the select box?
Hi, the events are on the Select Box....
Jun 13 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.