Jump to content

listbox search function help


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;


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


Link to comment
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.

Link to comment
Share on other sites

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.

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.