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

open select dropdown on button click javascript
javascript change select options dynamically
open select programmatically
javascript set selected option by text
open select dropdown on button click jquery
new option javascript
javascript select
open select on label click

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

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

HTMLSelectElement add ability to show option list programmatically , The ability to open a HTMLSelectElement's option list from javascript doesn't exist​. One possible of use of this functionality is an annotated tutorial that Auto-​converting links to the HTML Living Standard to use multipage locations markup I can also decide that its open. In my JS:; // true = false;  The little-known Option() constructor can be used to create new HTML option elements. So, depending on how you choose to approach this, you can write some pretty efficient code that side-steps the normally verbose syntax of document.createTextNode(), document.createElement(), and document.appendChild() methods.

This works on Google Chrome

dropDown = function (elementId) {
    var dropdown = document.getElementById(elementId);
    try {
    } catch(e) {

    return false;

showDropdown = function (element) {
    var event;
    event = document.createEvent('MouseEvents');
    event.initMouseEvent('mousedown', true, true, window);

HTML DOM Select Object, Select Object. You can access a <select> element by using getElementById(): Description. options, Returns a collection of all the options in a drop-down list  Please don't use script in HTML attributes. It's just as easy to do what you did properly separating HTML and JS – Juan Mendes Jun 13 '12 at 21:44

I use this... but it requires the user to click on the select box...

Here are the 2 javascript functions

function expand(obj)
    obj.size = 5;
function unexpand(obj)
    obj.size = 1;

then i create the select box

<select id="test" multiple="multiple" name="foo" onFocus="expand(this)" onBlur="unexpand(this)">
<option >option1</option>
<option >option2</option>
<option >option3</option>
<option >option4</option>
<option >option5</option>

I know this code is a little late, but i hope it helps someone who had the same problem as me.

ps/fyi i have not tested the code above (i create my select box dynamically), and the code i did write was only tested in FireFox.

HTML DOM Select options Collection, Well organized and easy to understand Web building tutorials with lots of examples of how to use HTML, CSS, JavaScript, SQL, PHP, Python, Bootstrap, Java  There is an alternate solution i found for this problem. Just add a theme to your select box like Selectize.js it will convert your select box into ul li html tags but works as select box. You can easily hide show ul li's on jquery events.

I had this problem...and found a workable solution.

I didn't want the select box to show until the user clicked on some plain HTML. So I overlayed the select element with opacity=.01. Upon clicking, I changed it back to opacity=100. This allowed me to hide the select, and when the user clicked the text the select appeared with the options showing.

Programmatically Preselect Dropdown Using Javascript, How to programmatically preselect a dropdown list using javascript. selected item on an HTML dropdown list after the page has been rendered using javascript. </select>. As you can see, the initially selected item is the first item on the list. If this is required then it is not possible to add the selected="selected​" attribute. Returns the <option> element from the collection with the specified index (starts at 0). Adds an <option> element into the collection at the specified index. Returns the <option> element from the collection with the specified index (starts at 0). Returns the <option> element from the collection with the specified id.

This is very late, but I thought it could be useful to someone should they reference this question. I beleive the below JS will do what is asked.


<select>, The HTML select element represents a control that provides a menu of options. Each <option> element should have a value attribute containing the data For further examples, see The native form widgets: Drop-down content. your own dropdown menu using non-semantic elements, JavaScript, and  Neither does visibility: hidden. In either case, they all show up in the select dropdown. You can disable options, but then they're still there, just greyed out. Hence, this code forcibly removes/appends the options. Of course, it might make more sense to simply remove/append only the non-default options.

SCR19: Using an onchange event on a select element without , HTML and XHTML with support for scripting. This technique uses the try/catch construct of JavaScript 1.4. The objective of this technique is to demonstrate how to correctly use an onchange event with a select element to update var which = selectObj.options[idx].value; // use the selected option value to retrieve the list of  The To Do List. Use CSS and JavaScript to create a "to-do list" to organize and prioritize your tasks.

How to set the default value for an HTML <select> element , Programming For Beginners: 10 Best HTML Coding Practices You Must Know · How to make an HTML link to open a folder? The select tag in HTML is used to create a dropdown list of options which can be p >Choose your plan below:</ p > How to hide div element by default and show it on click using JavaScript and​  Selecting an Option Using JavaScript : Option Select ComboBox « Form Control « JavaScript DHTML

Dropdown, A dropdown allows a user to select a value from a series of options. can be initialized directly on a select or with the matching HTML and a hidden input . A simple dropdown can open without Javascript An active dropdown has its menu open To activate a normal dropdown use $('.ui.dropdown').dropdown('​show');. The only way to accomplish this is to create a dynamic select box which functions just like the HTML select element. In this post I’m going to show you the way to create a fake select box that will open when clicked and when the user selects an option, the select box will automatically close.