title: Submitting 2 forms at the same time using JavaScript
body: <p>I'm trying to submit 2 forms at the same time, using javascript.
  However, it seems like only the 2nd submit is opened, and not the first.</p>
  
  <p>The code is fairly simple:</p>
  
  <pre><code>&lt;html&gt;
  &lt;body&gt;
  &lt;form id="report_0" method="POST" target="_blank" action="https://www.google.com"&gt;
     &lt;input type="hidden" name="test1" value="1"&gt;
     &lt;input type="submit" value="report_0"&gt;
  &lt;/form&gt;
  &lt;form id="report_1" method="POST" target="_blank" action="https://www.google.com"&gt;
     &lt;input type="hidden" name="test2" value="2"&gt;
     &lt;input type="submit" value="report_1"&gt;
  &lt;/form&gt;
  &lt;script&gt;
      document.getElementById("report_0").submit();
      document.getElementById("report_1").submit();
      &lt;/script&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>I <strong>cannot</strong> use ajax or equivalent as it has to be the 'native' POST (due to CORS issues)</p>
  
  <p>I've read somewhere that you can't submit 2 forms at once, this doesn't make sense to me. I've tried changing the target from "_blank" to "form1" &amp; "form2" but still nothing.</p>
  
  <p>Your assistance will be highly appreciated :)</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>Here is what I actually use:</p>
  
  <pre><code>for (....) {
         var form = document.createElement("form");
         form.setAttribute("name", "report_"+i);
         form.setAttribute("method", "POST");
         form.setAttribute("target", "_blank");
         form.setAttribute("action", action);
  
         for (var key in parms) {
             var field = document.createElement("input");
             field.setAttribute("type", "hidden");
             field.setAttribute("name", key);
             field.setAttribute("value", parms[key]);
             form.appendChild(field);
         }
         console.log(form);
         document.body.appendChild(form);
         form.submit();
         document.body.removeChild(form);
  }
  </code></pre>