Answers for "javascript select multiple values"

0

how to get values from select multiple in js

document.getElementById('submit').onclick = function() {
  var selected = [];
  for (var option of document.getElementById('pets').options) {
    if (option.selected) {
      selected.push(option.value);
    }
  }
  alert(selected);
}
Posted by: Guest on August-11-2020
0

javascript select multiple values

const selected = document.querySelectorAll('#select-meal-type option:checked');
const values = Array.from(selected).map(el => el.value);
Posted by: Guest on March-30-2020

Code answers related to "javascript select multiple values"

Code answers related to "Javascript"

Browse Popular Code Answers by Language