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 :: reset form function javascript 
Javascript :: size of call stack js 
Javascript :: jest ReferenceError: TextEncoder is not defined 
Javascript :: add css in javascript 
Javascript :: js string startswith ignore case 
Javascript :: are you sure javascript 
Javascript :: document jquery 
Javascript :: javascript word count 
Javascript :: file input change event not firing angular 
Javascript :: useState settoggle 
Javascript :: javascript camera 
Javascript :: aos js 
Javascript :: jquery on load 
Javascript :: create path if not exist node js 
Javascript :: changing the active class on press 
Javascript :: js check if two array have the same element 
Javascript :: get checked radio button value jquery by name 
Javascript :: javascript padend 
Javascript :: jquery remove closest parent 
Javascript :: angular contains both .browserslistrc and browserslist 
Javascript :: delay javascript function 
Javascript :: react router history push parameter 
Javascript :: add variable inside regex in javascript 
Javascript :: Module Error (from ./node_modules/eslint-loader/dist/cjs.js): 
Javascript :: install gulp ubuntu 20.04 
Javascript :: jquery modal if clicked outside 
Javascript :: trigger send parameter 
Javascript :: Error: `createStackNavigator()` has been moved to `react-navigation-stack`. 
Javascript :: how to always run validators mongoose 
Javascript :: vue get store state 
ADD CONTENT
Topic
Content
Source link
Name
2+7 =