Answers for "change a select option javascript"

5

javascript select change selected

const options = Array.from(select.options);
options.forEach((option, i) => {
  if (option.value === use_id) select.selectedIndex = i;
});
Posted by: Guest on June-22-2020
5

javascript set html select value

// Get the html select element
var select = document.getElementById('<your select element id>');

// If you have a <option> like this:
// <option value="1">My Value Display text</option>

//Then your selected value of your select would be:

select.value = "1";
Posted by: Guest on September-29-2020
5

js select on change value

document.getElementById('my-select').addEventListener('change', function() {
  console.log('You selected: ', this.value);
});
Posted by: Guest on May-14-2020

Code answers related to "change a select option javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language