title: how to get the index of the first loop for another array jquery
body: <p>I am trying to access the index of the foreach loop to access the second element</p>
  
  <pre><code>$.each("input:checkbox[name=city[]]:checked", function (index, item) {
      var category = $('select[name="category[]["' + index + '"]"]').val();
      alert(category);
      var split = category = category.split('_');
      var category = split[0];
      if (category == "0") {
          alert('Please select hotel category');
          validate = "false";
          return false;
      }
      else {
          validate = "true";
      }
  });
  </code></pre>
  
  <p>This is my html</p>
  
  <pre><code>&lt;select name="category[]" 
           id="webmenus_&lt;?php echo $BPackageCityRelatedToCountry[$i]['city_id']; ?&gt;"      
           onchange="showValue(this.value)"
   &gt;
       &lt;option value="0" selected="selected" title="Please select hotel category"&gt;&lt;/option&gt;
       &lt;option value="5_&lt;?php echo $BPackageCityRelatedToCountry[$i]['city_id']; ?&gt;" title="/public/front_end/images/5star.png"&gt;&lt;/option&gt;
       &lt;option value="4_&lt;?php echo $BPackageCityRelatedToCountry[$i]['city_id']; ?&gt;" title="/public/front_end/images/4star.png"&gt;&lt;/option&gt;
       &lt;option value="3_&lt;?php echo $BPackageCityRelatedToCountry[$i]['city_id']; ?&gt;" title="/public/front_end/images/3star.png"&gt;&lt;/option&gt;
       &lt;option value="2_&lt;?php echo $BPackageCityRelatedToCountry[$i]['city_id']; ?&gt;" title="/public/front_end/images/2star.png"&gt;&lt;/option&gt;
       &lt;option value="1_&lt;?php echo $BPackageCityRelatedToCountry[$i]['city_id']; ?&gt;" title="/public/front_end/images/1star.png"&gt;&lt;/option&gt;
  &lt;/select&gt;
  </code></pre>
  
  <p>But i am getting as undefined. </p>
  
  <p>Thanks,</p>