[Javascript] searching a <select> list

Shawn Milo milo at linuxmail.org
Wed Jun 2 12:04:41 CDT 2004


No, I want to search anywhere in the string.

1.  If the list contains names, it is easier.
So, if "Milo, Shawn" is in the list,
I'd want the user to be able to type in the
first or last name.

2.  It's easier to try a few letters if the
user isn't sure of the exact spelling, or if
the last name is something like "du Quense", and
the user is not familiar with foreign names.

3.  If the list is store names, such as,
"311 Woodbridge Center"
"118 Lexington Ave"
the user would want to be able to type "lex" or "wood".
The same applies to a list of pieces of equipment.  
If the person is looking for "SIG Wrapper", they should
be able to type in "wrap".



I'm sure there are other reasons, depending upon the
situation.  Also, it's just interesting to type in
a couple of random letters, and see who in the list
has a name with a "op".  (Sophie, perhaps.)

Shawn




----- Original Message -----
From: Paul Novitski <paul at novitskisoftware.com>
Date: Wed, 02 Jun 2004 08:25:30 -0700
To: "[JavaScript List]" <javascript at LaTech.edu>
Subject: Re: [Javascript] searching a <select> list

> Shawn,
> 
> Wouldn't you want to search for the character string only at the beginning 
> of the list options?
> 
>          var regEx = new RegExp('^' + inText, 'i');
> 
> Curiously,
> Paul
> 
> 
> 
> At 04:33 AM 6/2/2004, Shawn Milo wrote:
> >Just in a sharing mood.  I put this together yesterday for something
> >I'm working on at work.  There is a drop-down with about 170 names in
> >it, and I added a text box which allows users to type in a few characters
> >and find the first match.
> >
> >   function searchList(inText, drpBox){
> >
> >       var iCount;
> >       var regEx = new RegExp(inText, 'i');
> >
> >       for (iCount=0; iCount<drpBox.length; iCount++){
> >          if (drpBox[iCount].value.match(regEx)){
> >             drpBox.selectedIndex = iCount;
> >             break;
> >          }
> >       }
> >
> >    }
> 
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> https://lists.LaTech.edu/mailman/listinfo/javascript




More information about the Javascript mailing list