title: jQuery: get value from different select tag with same name
body: <p>I was trying to get the value from different select tag with the same name using jQuery.</p>
  
  <p>The following is the HTML</p>
  
  <pre><code>&lt;div class="row"&gt;      
    &lt;div class="col-md-3"&gt;
      &lt;h1&gt;&lt;i class="fa fa-glass" aria-hidden="true"&gt;&lt;/i&gt;&lt;/h1&gt;
      &lt;select class="form-control SelectWine" id="SelectWine" name="SelectWine[]"&gt;
        &lt;option value="1"&gt;Red&lt;/option&gt; &lt;option value="2"&gt;Green&lt;/option&gt; &lt;option value="3"&gt;White&lt;/option&gt;                                             &lt;/select&gt;
    &lt;/div&gt;
    &lt;div class="col-md-3"&gt;
      &lt;h1&gt;&lt;i class="fa fa-glass" aria-hidden="true"&gt;&lt;/i&gt;&lt;/h1&gt;
      &lt;select class="form-control SelectWine" id="SelectWine" name="SelectWine[]"&gt;
        &lt;option value="1"&gt;Red&lt;/option&gt; &lt;option value="2"&gt;Green&lt;/option&gt; &lt;option value="3"&gt;White&lt;/option&gt;                                             &lt;/select&gt;
    &lt;/div&gt;
  
  &lt;/div&gt;
  </code></pre>
  
  <p>The following is how I am accessing in jQuery:</p>
  
  <pre><code>$('.SelectWine').each(function (index){
         var wineId=[];
          wineId.push($(this).val());
          console.log('Wid',wineId[0]);
          console.log('Wid',wineId[1]);
          console.log('Wid',wineId[2]);
     });
  </code></pre>
  
  <p>I am getting console log as following</p>
  
  <pre><code>Wid 1
  Wid undefined
  Wid undefined
  Wid 3
  Wid undefined
  Wid undefined
  </code></pre>
  
  <p>I'm guessing each time it's overriding the value. But i need to store the values from each select tag in to one array. </p>
  
  <p><strong>Note</strong>: the first select tag is in the default(index 1) and second one i selected the third option(index 3).</p>
  
  <p>This code is to get the users input for 2 or 3 different products and store it into the cookie for further use, but first i need to store it as array then i am able to store as json array in the cookie. </p>
  
  <p>I tried accessing through the name of the element but it's only responding for accessing using the id. </p>
  
  <p>I was trying for hours, can't figure out a way. your help will be great !!</p>