Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

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);
}
Source by www.techiedelight.com #
 
PREVIOUS NEXT
Tagged: #values #select #multiple #js
ADD COMMENT
Topic
Name
4+4 =