How to Programmatically Tell an HTML Select to Drop Down (For Example, Due to Mouseover)

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

You can't do this with a HTML select tag, but you can do it with JavaScript and HTML. There are variety of existing controls that do this - for instance, the "suggest" list attached to the SO "interesting/ignored tag" entry, or Gmail's lookup for email adresses.

There are many JavaScript+HTML controls that provide this capability--look for autocomplete controls for ideas.

See this link for the Autocomplete control...http://ajaxcontroltoolkit.codeplex.com/

Is it possible to use JS to open an HTML select to show its option list?

Unfortunately there's a simple answer to this question, and it's "No"

Programmatically choose item in select drop down

First get a handle on that select somehow:

var select = document.getElementsByTagName("SELECT")[0];

Then manipulate the selectedIndex property (I believe it's a zero-based index):

select.selectedIndex = 1;


Related Topics



Leave a reply



Submit