11

Possible Duplicate:
How can you programmatically tell an HTML SELECT to drop down (for example, due to mouseover)

Is there a way to programmatically display/open a drop down menu (<select>)?

Community
  • 1
  • 1
nickf
  • 537,072
  • 198
  • 649
  • 721
  • See: http://stackoverflow.com/questions/249192/how-can-you-programmatically-tell-an-html-select-to-drop-down-for-example-due-t – Christian C. Salvadó May 10 '10 at 04:29
  • 1
    @CMS: thanks for the link - I'm voting to close this now. – nickf May 10 '10 at 04:32
  • 1
    Possible solution (shameless plug): http://stackoverflow.com/questions/249192/how-can-you-programmatically-tell-an-html-select-to-drop-down-for-example-due/10136523#10136523 – Xavier Ho Apr 13 '12 at 07:06

2 Answers2

4

After trying a few things, I could not get it to work. So maybe the answer might be "it is impossible". Sorry!

The only way you could probably do it is to use one of the jQuery plugins that turn a normal select element into normal elements that are styled. Then it should be trivial to set display: block on one of the elements the plugin produces.

alex
  • 479,566
  • 201
  • 878
  • 984
0

I'll often program in a series of <select>/<option> tags, but then replace it with jQuery to become an anchor than spawns a <div> when clicked, and the <div> contains a <ul> of the options. This allows for better styling, and can be quite keyboard accessible if you choose to program that in.

I mostly do it because my designer insists upon non-native form elements.

Alex Mcp
  • 19,037
  • 12
  • 60
  • 93
  • Can be downright annoying when the designer ignores usability with their *custom* input boxes. – alex May 10 '10 at 04:25
  • But aside from the PITA it causes, you CAN make it quite usable by assigning key shortcuts to different options or otherwise enhancing the behavior of the list (if it makes sense to, obviously) – Alex Mcp May 10 '10 at 04:26
  • For most sites, if they are ugly, people will not use them.. so sometimes you have little choice :( – eselk Dec 13 '12 at 16:19