title: Working code to search within dropdown menu
body: <p>Someone helped me with this earlier, but there is one problem and I already closed that question.  I do not want to use <code>JQuery</code>. The following code works, it allows you to search a dropdown menu:</p>
  
  <pre><code>&lt;html&gt;
    &lt;head&gt;
      &lt;script type="text/javascript"&gt;
      function searchSel() 
      {
        var input = document.getElementById('realtxt').value.toLowerCase(),
            len = input.length,
            output = document.getElementById('realitems').options;
        for(var i=0; i&lt;output.length; i++)
          if (output[i].text.toLowerCase().slice(0, len) == input)
            output[i].selected = true;
        if (input == '')
          output[0].selected = true;
      }
      &lt;/script&gt;
    &lt;/head&gt;
    &lt;body&gt;
      &lt;form&gt;
        search &lt;input type="text" id="realtxt" onkeyup="searchSel()"&gt;
        &lt;select id="realitems"&gt;
          &lt;option value=""&gt;select...&lt;/option&gt;
          &lt;option value="1"&gt;Power hungry&lt;/option&gt;
          &lt;option value="2"&gt;Super man&lt;/option&gt;
          &lt;option value="3"&gt;Hyperactive&lt;/option&gt;
          &lt;option value="4"&gt;Bored&lt;/option&gt;
          &lt;option value="5"&gt;Human&lt;/option&gt;
        &lt;/select&gt;
      &lt;/form&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p><strong>Here is the problem.</strong></p>
  
  <p>It is only limited to the matching first letters of the first word.  So if you typed in <code>Super</code> for Super Man, it would work.  But if you typing with <code>Man</code> it will not show. Is there a way to make it match the whole string for a matching value?  Thanks.</p>