Drop down box using recordsets

In the code below RSName is a recordset and Company Name is a field within it.

<select name="CoName">
<OPTION Value="Company" selected>Company</OPTION>
      <% Do until RsName.EOF %>
   <OPTION Value="<%=RsName("Company Name")%>"><%=RsName("Company Name")%></OPTION>
   <%RsName.MoveNext
      loop
      %>
</select>

On a webpage this will produce a drop down box.  Suppose I am searching for a company Imperial chemical industries.  If I type "I" then it will go to companies beginning with I.  However if I then type M I will go to companies beginning with "M".  I want to get to companies beginning with "Im".

Is there a VBscript or Javascript function that would help?

When selecting a name from the Outlook addresses I can do the above e.g typing AB would give names beginning with AB.

Regards.
AlHal2Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

hesCommented:
Try this:

<input name="cntSearch" type="text" id="Search"  size="30" maxlength="50" onkeyup="autoComplete(cntSearch,CoName,'text',true)">
<SCRIPT LANGUAGE=javascript>
<!--
function autoComplete (field, select, property, forcematch) {
      var found = false;
      for (var i = 0; i < select.options.length; i++) {
      if (select.options[i][property].toUpperCase().indexOf(field.value.toUpperCase()) == 0) {
            found=true; break;
            }
      }
      if (found) { select.selectedIndex = i; }
      else { select.selectedIndex = -1; }
      if (field.createTextRange) {
            if (forcematch && !found) {
                  field.value=field.value.substring(0,field.value.length-1);
                  return;
                  }
            var cursorKeys ="8;46;37;38;39;40;33;34;35;36;45;";
            if (cursorKeys.indexOf(event.keyCode+";") == -1) {
                  var r1 = field.createTextRange();
                  var oldValue = r1.text;
                  var newValue = found ? select.options[i][property] : oldValue;
                  if (newValue != field.value) {
                        /*field.value = newValue;*/
                        var rNew = field.createTextRange();
                        rNew.moveStart('character', oldValue.length) ;
                        rNew.select();
                        }
                  }
            }
      }

//-->
</SCRIPT>

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
AlHal2Author Commented:
This creates a textbox which I can use to manipulate the drop down box.  Can I manipulate the drop down box without needing a text box?
AlHal2Author Commented:
The example I gave was Outlook.  I should have used the example of Intellisense.  For example after I type a dot the relevant options appear.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Development Software

From novice to tech pro — start learning today.