0

I have a dropdown. I have a button too. I have special requirement.

When a user click on the button, the dropdown should be expanded.

3
  • what you mean by "expanded" ? Commented Jun 7, 2012 at 12:25
  • jqueryui.com/demos/autocomplete/#combobox Commented Jun 7, 2012 at 12:28
  • shyju onnun ariyillengil mindathiri Commented Jun 8, 2012 at 5:08

2 Answers 2

1

You probably want to build a custom dropdown menu that has some kind of expand() method that shows the options in the dropdown. The default dropdown menu does not have such a thing, so you're stuck there.

Sign up to request clarification or add additional context in comments.

Comments

0

While you can't achieve exactly what you want, I came up with alternative way. When the button is clicked you can set the drop down size dynamically to the amount of items it got, causing it to "open" and show all the items.

Then, when selecting an item you can set the size back to 1. This effectively has the same look and feel like what you want.

Complete code for this would be:

window.onload = function() {
    var oDDL = document.getElementById("myselect");
    oDDL.onchange = function() {
        //drop down item selected, reset size back to 1 to "close" the list:
        this.size = 1;
    };

    var oButton = document.getElementById("btnOpenDropDown");
    oButton.onclick = function() {
        //set size to number of items to "open" the list:
        oDDL.size = oDDL.options.length;
        oDDL.focus();
    }
};​

Live test case.

Comments

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.