title: How to get all selected values of a multiple select box?
body: <p>I have a <code>&lt;select&gt;</code> element with the <code>multiple</code> attribute. How can I get this element's selected values using JavaScript? </p>
  
  <p>Here's what I'm trying:</p>
  
  <pre><code>function loopSelected() { 
      var txtSelectedValuesObj = document.getElementById('txtSelectedValues');
      var selectedArray = new Array();
      var selObj = document.getElementById('slct'); 
      var i;
      var count = 0;
      for (i=0; i&lt;selObj.options.length; i++) { 
          if (selObj.options[i].selected) {
              selectedArray[count] = selObj.options[i].value;
              count++; 
          } 
      } 
      txtSelectedValuesObj.value = selectedArray;
  }
  </code></pre>