Click here to Skip to main content
15,900,906 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: Requirement in Drop down list Pin
Christian Graus7-Aug-07 20:33
protectorChristian Graus7-Aug-07 20:33 
GeneralRe: Requirement in Drop down list Pin
Michael Sync7-Aug-07 22:15
Michael Sync7-Aug-07 22:15 
GeneralRe: Requirement in Drop down list Pin
Hari_10107-Aug-07 22:21
Hari_10107-Aug-07 22:21 
GeneralRe: Requirement in Drop down list Pin
Hari_10108-Aug-07 1:52
Hari_10108-Aug-07 1:52 
GeneralRe: Requirement in Drop down list Pin
Michael Sync8-Aug-07 7:42
Michael Sync8-Aug-07 7:42 
GeneralRe: Requirement in Drop down list Pin
Hari_10108-Aug-07 20:49
Hari_10108-Aug-07 20:49 
GeneralRe: Requirement in Drop down list Pin
Hari_10108-Aug-07 23:50
Hari_10108-Aug-07 23:50 
GeneralRe: Requirement in Drop down list Pin
Michael Sync9-Aug-07 15:28
Michael Sync9-Aug-07 15:28 
Hello Hariharan,

Sorry for late reply. Yesterday was a holiday (Birthday of S'pore[^])

I have tested my code that I gave you earlier. There is only thing that we need to change in my code.

We should use selectedIndex selectList.selectedIndex = 2; instead of selectList.options[i].select = true;

The completed code is as below ~

<script language="javascript" type="text/javascript"><br />
      var pressedKeyString = "";<br />
      var delay = 1000;<br />
      var timeID = null;<br />
      function move(){<br />
        <br />
        var selectList = document.getElementById('DropDownList1');<br />
        var arr = new Array();<br />
        <br />
        var idx = 0;<br />
        <br />
        for(var i = 0; i < selectList.options.length-1; i++){           <br />
           if(selectList.options[i].value.length >= pressedKeyString.length){<br />
             if(pressedKeyString.toLowerCase() == selectList.options[i].value.substring(0,pressedKeyString.length).toLowerCase()){                              <br />
                 selectList.selectedIndex = i;<br />
                 i=selectList.options.length;                                  <br />
                 alert(pressedKeyString);<br />
             }<br />
           }                      <br />
        }<br />
        <br />
        pressedKeyString = "";<br />
      }<br />
      <br />
      function foo(e,id){<br />
        if(timeID != null)clearTimeout(timeID);<br />
        timeID = setTimeout("move();",delay);<br />
        <br />
        var key;<br />
        if(window.event) // IE<br />
        {<br />
           key = e.keyCode<br />
        }<br />
        else if(e.which) // Netscape/Firefox/Opera<br />
        {<br />
           key = e.which<br />
        }        <br />
        <br />
        var pressKey = String.fromCharCode(key);<br />
        pressedKeyString += pressKey;<br />
        <br />
        <br />
        <br />
      }<br />
    </script>



Note that "onkeypress" event is a javascript event (not server-side event).

As I mentioned my idea, the character that you typed will keep on appending to the string called pressedKeyString. (while you are typing, the select list will be changed by default. (this is what we don't want)). After finished typing (timer will count to 1000 minisecound), then the dropdown list will be changed to the option which is matched with the characters that you enter. (eg: if you type "pe" then dropdown list will select to "Peter".)


Hope it helps. Let me know whether it works for you or not..

Thanks and Regards,
Michael Sync ( Blog: http://michaelsync.net)

If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you. Smile | :)

GeneralRe: Requirement in Drop down list Pin
Hari_10109-Aug-07 18:38
Hari_10109-Aug-07 18:38 
GeneralRe: Requirement in Drop down list Pin
Michael Sync9-Aug-07 20:01
Michael Sync9-Aug-07 20:01 
GeneralRe: Requirement in Drop down list Pin
Hari_10109-Aug-07 20:21
Hari_10109-Aug-07 20:21 
GeneralYou forget to uncomment Pin
Michael Sync10-Aug-07 8:30
Michael Sync10-Aug-07 8:30 
GeneralRe: You forget to uncomment Pin
Hari_101012-Aug-07 18:12
Hari_101012-Aug-07 18:12 
GeneralRe: You forget to uncomment Pin
Hari_101012-Aug-07 19:06
Hari_101012-Aug-07 19:06 
GeneralRe: You forget to uncomment Pin
Michael Sync12-Aug-07 19:45
Michael Sync12-Aug-07 19:45 
GeneralRe: You forget to uncomment Pin
Hari_101012-Aug-07 19:58
Hari_101012-Aug-07 19:58 
QuestionProblem with Header Background image? Pin
chand107-Aug-07 19:50
chand107-Aug-07 19:50 
QuestionDisplay DB records In Flash Pin
kirthikirthi7-Aug-07 19:22
kirthikirthi7-Aug-07 19:22 
AnswerRe: Display DB records In Flash Pin
Christian Graus7-Aug-07 19:29
protectorChristian Graus7-Aug-07 19:29 
GeneralRe: Display DB records In Flash Pin
kirthikirthi7-Aug-07 20:03
kirthikirthi7-Aug-07 20:03 
GeneralRe: Display DB records In Flash Pin
Christian Graus7-Aug-07 20:08
protectorChristian Graus7-Aug-07 20:08 
Questionsession_end Pin
Sonia Gupta7-Aug-07 19:07
Sonia Gupta7-Aug-07 19:07 
AnswerRe: session_end Pin
sulabh20207-Aug-07 22:33
sulabh20207-Aug-07 22:33 
AnswerRe: session_end Pin
N a v a n e e t h7-Aug-07 22:39
N a v a n e e t h7-Aug-07 22:39 
GeneralRe: session_end Pin
Sonia Gupta7-Aug-07 23:39
Sonia Gupta7-Aug-07 23:39 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.