Search
 
SCRIPT & CODE EXAMPLE
 

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);
}
Comment

javascript select multiple values

const selected = document.querySelectorAll('#select-meal-type option:checked');
const values = Array.from(selected).map(el => el.value);
Comment

PREVIOUS NEXT
Code Example
Javascript :: api fetch in react js 
Javascript :: filter repetition multidimensional array javascript 
Javascript :: javascript slice array 
Javascript :: javascript push dictionary into array 
Javascript :: convert array to object 
Javascript :: vuetify autocomplete get input value 
Javascript :: get match number array javascript 
Javascript :: generate random special characters javascript 
Javascript :: js object some 
Javascript :: enable button 
Javascript :: node get package.json version 
Javascript :: discord js lockdown command 
Javascript :: javascript how to take off a decimal 
Javascript :: jquery compare two arrays return difference 
Javascript :: onchange value in hidden input 
Javascript :: json decode android 
Javascript :: typescript interface with unknown keys 
Javascript :: Addition aruments in javascript 
Javascript :: Multiple children were passed to <Link with `href` of `/escritorio/opcion1` but only one child is supported 
Javascript :: change href javascript 
Javascript :: replace each string by another string javascript 
Javascript :: clear a div 
Javascript :: react js pdf generate from html 
Javascript :: array.from javascript 
Javascript :: react build command 
Javascript :: how to add d3.js in angular 
Javascript :: empty input field on click 
Javascript :: iso 8601 date to Js date 
Javascript :: use svg image in next js 
Javascript :: rotate array by d elements javascript 
ADD CONTENT
Topic
Content
Source link
Name
4+2 =