title: Javascript: Using multiple forms to return a single output
body: <p>The page I'm currently working is a dashboard for an online publisher. The way it works is that it uses a foreach loop to create an instance of an editor form for each article. What I'm trying to do is add checkboxes to each instance that can add a value to a subtotal at the bottom of the page. I can only get it to work if the output is contained within the same form.</p>
  
  <p>So my question actually is: Is there a way to to use inputs from multiple forms and return a single output?</p>
  
  <p>Simplified PHP code for each instance:</p>
  
  <pre><code>foreach ($Articles as $idx =&gt; $Article){
      echo &lt;form action='/gatekeeper.php' method='POST' target='_SAVE{$Article["ID"]}' onchange='submit()'&gt;
      echo &lt;input type="checkbox" onClick="checkTotal()" /&gt;
  }
  </code></pre>
  
  <p>And here is the JavaScript code.</p>
  
  <pre><code>function checkTotal() {
  document.listForm.total.value = '';
  var sum = 0;
  for (i=0;i&lt;document.listForm.choice.length;i++) {
    if (document.listForm.choice[i].checked) {
      sum = sum + parseInt(document.listForm.choice[i].value);
    }
  }
  document.listForm.total.value = sum;
  </code></pre>
  
  <p>}</p>