Results 1 to 5 of 5

Thread: search inside a option

  1. #1
    Join Date
    Sep 2010
    Posts
    8
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default search inside a option

    I saw a script where when you type someword in textbox and the option field also highlighting the word if was exist in the option field.

    for example:


    do anyone know any script, thanks!

  2. #2
    Join Date
    Dec 2008
    Location
    Portsmouth, UK
    Posts
    1,772
    Thanks
    2
    Thanked 410 Times in 405 Posts

    Default

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    
    <head>
      <title></title>
    <script type="text/javascript">
    /*<![CDATA[*/
    
    function Select(ip,sel){
     sel=document.getElementById(sel);
     var opts=sel.options;
     var txt=ip.value.split(' ');
     for (var s,z0=0;z0<opts.length;z0++){
      opts[z0].selected=false;
      s=opts[z0].text.split(' ');
      for (var z0a=0;z0a<txt.length;z0a++){
       for (var z0b=0;z0b<s.length;z0b++){
        if (txt[z0a]&&s[z0b]&&txt[z0a].toUpperCase()==s[z0b].toUpperCase()){
         opts[z0].selected=true;
        }
       }
      }
     }
    }
    
    /*]]>*/
    </script>
    </head>
    
    <body>
    <input name="fred" onkeyup="Select(this,'tst');"/>
    <select name="tst" size="3" multiple="multiple">
     <option>Tom</option>
     <option>****</option>
     <option>Harry Tom</option>
    </select>
    </body>
    
    </html>
    Vic
    God Loves You and will never love you less.
    http://www.vicsjavascripts.org/Home.htm
    If my post has been useful please donate to http://www.operationsmile.org.uk/

  3. #3
    Join Date
    Sep 2010
    Posts
    8
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    thank you so much, but doesn't seems to highlight anything.
    sorry to be rude at the 1st time.

  4. #4
    Join Date
    Dec 2008
    Location
    Portsmouth, UK
    Posts
    1,772
    Thanks
    2
    Thanked 410 Times in 405 Posts

    Default

    oops

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    
    <head>
      <title></title>
    <script type="text/javascript">
    /*<![CDATA[*/
    
    function Select(ip,sel){
     sel=document.getElementById(sel);
     var opts=sel.options;
     var txt=ip.value.split(' ');
     for (var s,z0=0;z0<opts.length;z0++){
      opts[z0].selected=false;
      s=opts[z0].text.split(' ');
      for (var z0a=0;z0a<txt.length;z0a++){
       for (var z0b=0;z0b<s.length;z0b++){
        if (txt[z0a]&&s[z0b]&&txt[z0a].toUpperCase()==s[z0b].toUpperCase()){
         opts[z0].selected=true;
        }
       }
      }
     }
    }
    
    /*]]>*/
    </script>
    </head>
    
    <body>
    <input name="fred" onkeyup="Select(this,'tst');"/>
    <select id="tst" size="3" multiple="multiple">
     <option>Tom</option>
     <option>****</option>
     <option>Harry Tom</option>
    </select>
    
    </body>
    
    </html>
    Vic
    God Loves You and will never love you less.
    http://www.vicsjavascripts.org/Home.htm
    If my post has been useful please donate to http://www.operationsmile.org.uk/

  5. The Following User Says Thank You to vwphillips For This Useful Post:

    Lozu (09-24-2010)

  6. #5
    Join Date
    Sep 2010
    Posts
    8
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    thanks you so much... works 100%.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •