@mkmanning

many thanks!! All i needed to do is add a text box with a keyup event
and change the regular expression to match everything and not just the
first beginning of the last name.

Here is the solution in case anyone else is  searching. Thanks
again.

<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js";></script>
<script>
  $(document).ready(function(){
        //cache the original select and options
        var selList = $('select'), opts = selList.find('option');

        //filters by first letter of last name as option text
        function filterList(ltr){
                selList.empty();
                if(ltr==='All' || ltr==''){
                        selList.append(opts);
                        return;
                }
               // var re = new RegExp("^"+ltr,"i");//, newopts = '';
                var re = new RegExp(ltr,"i");



                $.each($.grep(opts,function(o,i){return re.test($
(o).text());}),
                function(){
                        selList.append(this);
                });
        }

        $('#search').keyup(function(){
                filterList( $('#search').val() );
        });

});
  </script>


</head>

<body>

<!--  <span>All</span> <span>Be</span> ... <span>W</span>  -->
<input type="text" id="search" " ></input>
<select size="6">
<option>Bellucci, Monica</option>
<option>Bernhardt, Daniel</option>
<option>Chou, Collin</option>
<option>Fishburne, Laurence</option>
<option>Gaye, Nona</option>
<option>Hulme, Lachy</option>
<option>Lees, Nathaniel</option>
<option>Lennix, Harry J.</option>
<option>McColm, Matt</option>
<option>Moss, Carrie-Anne</option>
<option>O'Reilly, Genevieve</option>
<option>Perrineau, Harold Jr.</option>
<option>Pinkett Smith, Jada</option>
<option>Rayment, Adrian</option>
<option>Rayment, Neil</option>
<option>Reeves, Keanu</option>
<option>Spence, Bruce</option>
<option>Weaving, Hugo</option>
<option>Wilson, Lambert</option>
<option>Wong, Anthony</option>
</select>
</body>
</html>

Reply via email to