If no option is selected then nothing will be returned. How to set the layout weight of a TextView programmatically in Android using Kotlin? How to convert a string into number in PHP? G. Raghavender. If the user selects a new option, the new value will not be printed to the log. You are missing How can I remove all child elements of a DOM node in JavaScript? The value property can be used to set or update the value of a select element. Here is the HTML for the examples in this article. How to set placeholder value for input type date in HTML 5 ? Learn more. javascript set html select value. The following link will give you the list of properties you can work with on the select . How to append HTML code to a div using JavaScript ? Alfreda Hunter said: The document.forms method takes the name attribute to locate the form and its element. This will increase your understanding and make you a better developer. As mentioned in the posts, value property is nonstandard and does not work with IE. John Starr said: array_length = arr.length; Then, simply call the Math.random () method to get a floating-point value and then multiply that number with the length of the array to get the range between 0 and array length: value = Math.random () * array_length; This line will return floating point values, but they are no good when it comes to being , Jacqueline Gaul said: var mySelect = document.getElementById( 'my-select-id' ); mySelect.value = 7; You can also get the selected option by value just the same way: console.log( mySelect.value ); What I was looking for was a better way to set the values of a multiselect () but as it turns out - it seems you have . This property returns a string representing the value attribute of the