title: loop and submit form jquery
body: <p>I have 2 form. When I submit frm1, i have some checked option and use variable checkedValues to store it.</p>
  
  <p>I loop in each checked option, change value to frm2, submit it and open a popup after 3 second. But it not work with submit form 2 and setTimeout function. </p>
  
  <p>Does anyone have any ideas to solve this?</p>
  
  <pre><code>&lt;form  action="" method="post" name='frm1'&gt;
      &lt;input type="checkbox" name="1" id="1" value="1" class="checkbox"&gt;
      &lt;input type="checkbox" name="2" id="2" value="1" class="checkbox"&gt;
      &lt;input type="checkbox" name="3" id="3" value="0" class="checkbox"&gt;
      &lt;input type="checkbox" name="4" id="4" value="0" class="checkbox"&gt;
      &lt;input type="submit" value='add'&gt;
  &lt;/form&gt;
  
  &lt;form action='http://example.com' method='post' name='frm2' target="_blank"&gt;
      &lt;input type="text" name="fname" class="form-control" value=''&gt;
      &lt;input type="text" name="fvalue"class="form-control" value=''&gt;
  &lt;/form&gt;
  
  &lt;script&gt;
  $('#add').click(function(){
      var store= &lt;?php echo json_encode($store)?&gt;;
      var checkedValues = $('input:checkbox:checked').map(function() {
              return this.id;
           }).get();
  
      $.each(checkedValues, function(index,val) {
  
          document.frm2.fname.value = store[val]['name'];
          document.frm2.fvalue.value = store[val]['value'];
  
          document.frm2.submit(); // not working
  
          setTimeout(function () {       // not working
               window.open("http://example.com/client, "_blank"), 3000);
           });
      });
  });
  &lt;/script&gt;
  </code></pre>