Answers for "html select multiple show selected"

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
3

how to choose multiple option from select option

<!-- JUST ADD multiple ATTRIBUTE WITHIN select ATTRIBUTE -->
Cars:<br>
<select name="car" multiple>
    <option value="Volvo">Volvo</option>
    <option value="Thar">Thar</option>
    <option value="Audi">Audi</option>
</select>
Posted by: Guest on August-23-2020

Code answers related to "html select multiple show selected"

Browse Popular Code Answers by Language