Results 1 to 2 of 2

Thread: Dynamic list box

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Feb 1999
    Location
    Belfast
    Posts
    254
    Hi,
    I have a requirement for the following:

    In a text box, as a word is being typed the closest match is highlighted in a list box below.
    So for example if I start to type

    Lon ( for london )

    the list below immediately goes to L when I type L, then Lo and so on till I finally rest on London.
    I did ( with forum users help ) as similar thing involving dynamic list boxes with a 2D array in JavaScript. I presume this is much more involved.

    I just need some pointers i.e.
    Can it be done ( I am presuming yes ), major considerations ( time, effort etc ).

    Thanks in advance.

    Lenin.

  2. #2
    Frenzied Member sebs's Avatar
    Join Date
    Sep 2000
    Location
    Aylmer,Qc
    Posts
    1,606
    Is the code for mine:

    settime is my form name
    Glist is my select list.
    NewGuest is my textbox

    Code:
    function SearchGuest()
    {
    document.settime.Glist.options[0].selected = true;
    var ListLength = document.settime.Glist.length;
    var OptionContent='';
    var NewContent = document.settime.NewGuest.value;
    var ExitFun=false;
    
    if(NewContent!=''){
    	for(var x=1; x<ListLength;x++){
    		OptionContent = document.settime.Glist.options[x].text;
    		OptionContent = OptionContent.toLowerCase();
    		if(OptionContent.substring(0,NewContent.length)==NewContent.toLowerCase()){
    			document.settime.Glist.options[x].selected = true;
    			ExitFun = true;
    			break;
    			}
    		}
    	}
    }
    put onkeyup="SearchGuest();" in your input text.

Posting Permissions

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



Click Here to Expand Forum to Full Width