Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

get array of selected options from select element

  function getSelectValues(select) {
  var result = [];
  var options = select && select.options;
  var opt;

  for (var i=0, iLen=options.length; i<iLen; i++) {
    opt = options[i];

    if (opt.selected) {
      result.push(opt.value || opt.text);
    }
  }
  return result;
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #array #selected #options #select #element
ADD COMMENT
Topic
Name
6+1 =