title: Fetch value from multiple drop down with same name row wise
body: <p>I have a table like below-</p>
  
  <p><a href="https://i.stack.imgur.com/30U4l.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/30U4l.jpg" alt="enter image description here"></a></p>
  
  <p>the code of this table in my view is as following-</p>
  
  <pre><code> &lt;table class="table table-bordered"&gt;
     &lt;tr&gt;
     &lt;td&gt;Course Name&lt;/td&gt;
     &lt;td&gt;Class&lt;/td&gt;
     &lt;td&gt;Subject Name&lt;/td&gt;
     &lt;td&gt;Month&lt;/td&gt;
     &lt;td&gt;View&lt;/td&gt;
     &lt;/tr&gt;
     &lt;?php if(!empty($data)) { $i=1; foreach($data as $key =&gt; $value) { ?&gt;
        &lt;tr&gt;
          &lt;td&gt;&lt;?php echo $value-&gt;course_name; ?&gt;&lt;/td&gt;
          &lt;td&gt;&lt;?php echo $value-&gt;class_name; ?&gt;&lt;/td&gt;
          &lt;td&gt;&lt;?php echo $value-&gt;subjectName; ?&gt;&lt;/td&gt;
          &lt;td&gt;&lt;select class="form-control" id="month" data-parsley-required="true" data-parsley-error-message="Please Select Class"&gt;
               &lt;option value="" hidden="hidden"&gt;Select Month&lt;/option&gt;
               &lt;option value="1"&gt;January&lt;/option&gt;
               &lt;option value="2"&gt;Febuary&lt;/option&gt;
               &lt;option value="3"&gt;March&lt;/option&gt;
               &lt;option value="4"&gt;April&lt;/option&gt;
               &lt;option value="5"&gt;May&lt;/option&gt;
               &lt;option value="6"&gt;June&lt;/option&gt;
               &lt;option value="7"&gt;July&lt;/option&gt;
               &lt;option value="8"&gt;August&lt;/option&gt;
               &lt;option value="9"&gt;September&lt;/option&gt;
               &lt;option value="10"&gt;October&lt;/option&gt;
               &lt;option value="11"&gt;November&lt;/option&gt;
               &lt;option value="12"&gt;December&lt;/option&gt;
              &lt;/select&gt;
            &lt;/td&gt;
            &lt;td&gt;
             &lt;button id="&lt;?php echo $i;?&gt;" class="form-control" data-eid="&lt;?php echo $this-&gt;session-&gt;userdata('e_id');?&gt;"                                                data-subjectid="&lt;?php echo $value-&gt;subjectId;?&gt;" data-courseid="&lt;?php echo $value-&gt;course_id;?&gt;" data-classid="&lt;?php echo $value-&gt;class_id;?&gt;"&gt;
       View&lt;/button&gt;&lt;/td&gt;
   &lt;/tr&gt;
    &lt;?php $i++; } } ?&gt;
    &lt;/table&gt;
  </code></pre>
  
  <p>//javascript</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  $('button').on('click',function(){
     var eid = $(this).data('eid');
     var subId = $(this).data('subjectid');
     var courseId = $(this).data('courseid');
     var classId = $(this).data('classid');
     var month = $('#month').val();
     if(month == '')
      alert("Select Month");
     else { alert("okay"); }       
  &lt;/script&gt;
  </code></pre>
  
  <p>Whenever I select <code>month</code> and click the <code>view</code> button the page is redirected correctly, but when I select <code>month</code> in the second row and click the <code>view</code> button again it gives alert <code>select month</code>.</p>
  
  <p>I don't know how to differentiate all the dropdowns based on a name.</p>