Open the drop-down list of the Select on focus item.

Possible duplicate:
How can you programmatically report that you have selected HTML SELECT (e.g. because of a mouse)?

Is it possible to open the drop-down list of the Select element when the Select element receives focus?

I know that it automatically focuses when you click on it ... but I want it to work when you overlap it too.

+4
source share
2 answers

Unfortunately, the answer to your question is simply "No, it is not possible with current HTML and Javascript controls"

However, if you use jQuery and this plugin (https://github.com/fnagel/jquery-ui/wiki/Selectmenu) to select a menu, which I suppose you can do:

$("#idofSelect").selectmenu("open"); 

Another alternative to your idea, but maybe not so fantastic:

 document.getElementById("idOfSelect").setAttribute("size", 5); 

What this does is just make it multiline, so somehow it displays the parameters ... You can do this in focus, and then do another event when you click, where you reset its size is 1, and stop the event from spreading (so that onfocus is not called after ..) but, as I said, it is TEM professional, so either live with your choice as it is, or switch to jQuery, select the menu and enjoy opening and closing them dynamically as you wish :)

+1
source

As a starting point, if you use jQuery, you can use the trigger function, for example, if your select box has an identifier for "names", just call $ ('# names'). trigger ('click');

-3
source

All Articles