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.  


Thanks.
JimiJ13I T ConsultantAsked:
Who is Participating?
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:
Hi,
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:
http://jsfiddle.net/EE_RainerJ/ony4na95/

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

HTH
Rainer
0

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:
Rainer,

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

Open in new window

to
$("select")

Open in new window

HTH
Rainer
0
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.
0
SimonPrice3376Commented:
take a look at select2

Select 2

in my opinion this is one of the strongest out there for drop down menus
0
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
C#

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.