Auto drop list

When I focus to a DropDownList control, I need to click on it or press F4 to drop the list before I can select from it.
I wonder, if anyone has a method how to drop the list as soon as it got the focus.  

JimiJ13I T ConsultantAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Rainer JeschorCommented:
if you can use jQuery then the following could work:
$(document).ready(function() {
    $("#myDropDown").focus(function() {
        $(this).attr('size', $("option",$(this)).length);
    }).blur(function() {
        $(this).attr('size', 0);

Open in new window

Live sample:

Warning notice:
I tested this in IE11 and Chrome and already these two behave different.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
JimiJ13I T ConsultantAuthor Commented:

Thanks. In one web page, there are 4 dropdowns, how to make this function applicable for all?
Rainer JeschorCommented:
if they are the only one select elements then you simply can generalize the jQuery selector from

Open in new window


Open in new window

JimiJ13I T ConsultantAuthor Commented:
Thanks! It took me sometimes to find the right place to put it and observing it's behavior with the different browsers.
Anyway, this is a good alternative that we may consider in some cases.
take a look at select2

Select 2

in my opinion this is one of the strongest out there for drop down menus
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.