1

I found this demo autocomplete select, the code works great. I needed to have more than one autocomplete in my page but the jQuery autocomplete did not apply to more than one <select> (the first one).

<select  id="combobox" name = "type">
<option>...
<option>...
<option>...
</select>
<select  id="combobox" name = "status">
<option>...
<option>...
<option>...
</select>

I am new to jQuery. I can't figure this out by myself, hope someone can help me.

0

2 Answers 2

1

I did find the solution very simple all i needed to do is to declare more ids for the extra select i have so in the JQuery UI source go to this script

    $(function() {
    $("#combobox").combobox();
    $("#toggle").click(function() {
        $("#combobox").toggle();
    });
});

and add the extra select ids like this

    $(function() {
    $("#combobox").combobox();
    $("#combobox2").combobox();
    $("#toggle").click(function() {
        $("#combobox").toggle();
    });
});

so now all you need to do is to call each select with its own id

<select  class="combobox" name = "type">
<option>...
<option>...
<option>...
</select>
<select  class="combobox2" name = "status">
<option>...
<option>...
<option>...
</select>
Sign up to request clarification or add additional context in comments.

Comments

0

IDs must be unique. Use classes instead.

<select  class="combobox" name = "type">
<option>...
<option>...
<option>...
</select>
<select  class="combobox" name = "status">
<option>...
<option>...
<option>...
</select>

3 Comments

I did try that already but class="combobox" dose not apply the autocomplete, it has to be id. I think the only possibility is to change the JQuery code
No, it doesn't have to use IDs. Why don't you create a jsFiddle.net example of the problem you're having so we can all see it and reproduce it.
jsfiddle.net/hJCU4/1 you can try using class instead of id but that dosent work well this code works fine but if u can do better post it (jsfiddle seem to not support all the style normally the autocomplete look much better but that's not the point here )

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.