Multi-Key Combo box

Discussion in 'ASP .Net Building Controls' started by Jon Yates, Sep 2, 2003.

  1. Jon Yates

    Jon Yates Guest

    Hello all.

    I'm just wanting to know if there is a free component out
    there that will allow multi-key presses in a combo box.
    Currently, with the combo box, when you press a key it
    moves to the contents that start with that letter. If you
    press another key it then moves to another section.
    However, what I want is to be able to enter multiple keys.
    So if I were to press E N G it would bring up all words
    that start ENG.

    If there is a free component that would be great but I may
    need to write one so if anyone has any advice on that
    front, that would be great too!

    Cheers all,

    Jon
     
    Jon Yates, Sep 2, 2003
    #1
    1. Advertisements

  2. Hi

    Something like this should do it ( not tested )
    <html>
    <head>
    <script>
    function doItNow(s){
    var str = s.toLowerCase();
    var e = document.forms[0].mySelect;
    for(i=0;i<e.options.length;i++)
    {
    if(str.substring(0,str.length) ==
    e.options.text.toLowerCase().substring(0,str.length))
    {
    e.options.selected = true;
    break;
    }
    }
    }
    </script>
    </head>
    <body>
    <form>
    <input type="text" onkeyup="doItNow(this.value)">
    <select name="mySelect" size="4">
    <option>blast
    <option>bor
    <option>das
    <option>ka
    <option>kassi
    <option>strange options ;)
    <option>strange select options ;)
    </select>
    </form>
    </body>
    </html>


    Hope this helps and or gives you ideas
    --
    Best Regards
    Vidar Petursson
    ==============================
    Microsoft Scripting MVP
    http://www.microsoft.com/technet/scriptcenter
    ==============================
     
    Vidar Petursson, Sep 3, 2003
    #2
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.