Jump to content

Recommended Posts

<script type="text/javascript">

function listBoxSearch(){
	
	var input =  document.getElementById('searchBox'),
        output = document.getElementById('listBoxF');
		
	if(input.value != ''){
		
		for (var i = 0; i < output.options.length; i++){
			
			if(output.options[i].text.substring(0, input.value.length).toUpperCase() == input.value.toUpperCase()){
				
				output.options[output.options.length] = new Option(output.options[i].innerHTML, output.options[i].text);
			
			}
		}
		
		
		if (output.options.length == 1) {
		    output.selectedIndex = 0;
		}
		 
   }

}
	
</script>

It dosen`t work. It should work like this[DEMO in attached filed]

listbox_with_keybord_search.htm

Link to comment
https://forums.phpfreaks.com/topic/291019-listbox-search-function-help/
Share on other sites

Hi David,

  We need more precision from you in describing your question.  "It doesn't work" doesn't tell us enough.

 

What specifically have you tried?

What sort of debugging have you attempted?

How did you determine it isn't working, and have you narrowed down the problem in any way?

 

There are some very important tools for figuring out javascript problems, that are available in the browsers.  I tend to use Firefox with firebug because that's what I know the best, but there are similar tools for chrome and IE.  What are you using?

 

There is also the well known testbed site http://jsfiddle.net that you can use to test and share your html/javascript coding iterations.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.