-1

Say I have a simple select element looking like this:

<select onfocus="somefunction()">
    <option>Monday</option>
    <option>Tuesday</option>
    <option>Wednesday</option>
</select>

How would I create "somefunction()" such that it makes the select form element drop down, as if I had clicked on it?

user2066880
  • 4,825
  • 9
  • 38
  • 64
  • 1
    You can't do that with the standard form controls. You would need to use a JS/CSS drop down. – Sean Bright Jul 02 '13 at 21:27
  • are you looking for programatically trigger the click event? If yes the comment above has the solution. – Dynamikus Jul 02 '13 at 21:36
  • I think this might help [How can you programmatically tell an HTML SELECT to drop down (for example, due to mouseover)?][1] [1]: http://stackoverflow.com/questions/249192/how-can-you-programmatically-tell-an-html-select-to-drop-down-for-example-due – nouraty Jul 02 '13 at 21:49

1 Answers1

1

I know you didn't ask about jquery but how about using select2 instead? http://ivaynberg.github.io/select2/

phillip
  • 2,618
  • 19
  • 22