Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

get all values of a select javascrip

//u have to put a unique id on your html select tag!
var options = document.getElementById('mySelectID'). options;
/*u can use this istead if u dont have an id in your select,
if u have only 1 select in your html*/
var options = document.querySelector('select').options;

//options.length gives the array dimension of var options
for (let i = 0; i < options. length; i++) {
//log the value.
console. log(options[i]. value);
}  
 
PREVIOUS NEXT
Tagged: #values #select #javascrip
ADD COMMENT
Topic
Name
3+8 =