title: How to push values from a multiple select dropdown to an array?
body: <p>I am trying to push values into an array from a multiple select dropdown box. I am able to do that but what happens is that they are not pushed into the array in the order i set it up to via splice. It is added in the order it is set up on the select box. For example if i select the options in the order of [467, 341, 344, 657, 677], my array shows [344, 467, 677, 341, 657]. I want the array to show in order I have selected the options.
  This is my code:</p>
  
  <pre><code>&lt;select multiple class="yo"&gt;
      &lt;option value = "344"&gt;opt1&lt;/option&gt;
      &lt;option value = "467"&gt;opt2&lt;/option&gt;
      &lt;option value = "677"&gt;opt3&lt;/option&gt;
      &lt;option value = "341"&gt;opt1&lt;/option&gt;
      &lt;option value = "657"&gt;opt1&lt;/option&gt;
  &lt;/select&gt;
  
  var optVal = new Array();
          var tArray;
          $('.yo').each(function() {
              var newS = $(this).val(); 
              tArray = newS;
              optVal.splice(0, 0, tArray);
  
          });
  </code></pre>
  
  <p>Please help!</p>
  
  <p>Here is my Fiddle: <a href="https://jsfiddle.net/rprakash/e1xcd2gh/" rel="nofollow">https://jsfiddle.net/rprakash/e1xcd2gh/</a></p>