title: Foreach only prints one value from the array when using Ajax and onsubmitForm
body: <p>I have a PHP script that calls the Twitter 1.1 API, and returns 50 ID numbers. Then I am using a Foreach argument to print the results individualy on to the page.  I want to store each different ID number inside a button as a hidden value, and then use JQuery Ajax to post that value to a different PHP page for further processing without leaving or refreshing the page of 50 ID numbers.</p>
  
  <p>If I use this Foreach argument, the 50 ID numbers are ALL the first result in the array, rather than being 50 individual ID numbers which is not what I want:</p>
  
  <pre><code>foreach ($Results as $arrResult) {
      $IDstring = $arrResult['id_str'];
      print("&lt;form id='RT' onsubmit='return submitForm();'&gt;
                 &lt;input type='hidden' name='id' value=$IDstring&gt;
                 &lt;input type='submit' value='ReTweet'&gt;&lt;/form&gt;
      ");
  }
  </code></pre>
  
  <p>But, If I remove this section from the Foreach argument, 50 individual ID numbers are printed into into hidden values of the forms:</p>
  
  <pre><code>onsubmit='return submitForm();'
  </code></pre>
  
  <p>The problem is my JQuery script is listening for submitForm and without that line above the JQuery will not run. Here is my JQuery script:</p>
  
  <pre><code>&lt;script&gt;
  function submitForm() {
      $.ajax({type: 'POST', url: 'results.php', data: $('#RT').serialize()});
  
      return false;
  }
  &lt;/script&gt;
  </code></pre>
  
  <p>I know that removing onsubmit='return submitForm();' gives me 50 unique ID numbers from the Foreach, because this code will print 50 buttons which will each contain individual values. But because there is no JQuery script listening for submitForm I have to add <strong>method='post' action='results.php</strong> in order to POST the value of the button but this means the page results.php loads which is not what I want:</p>
  
  <pre><code>foreach ($Results as $arrResult) {
      $IDstring = $arrResult['id_str'];
      print("&lt;form id='form' method='post' action='results.php'&gt;
                 &lt;input type='hidden' name='id' value=$IDstring&gt;
                 &lt;input type='submit' value='ReTweet'&gt;&lt;/form&gt;");
  }
  </code></pre>
  
  <p>So, I want the foreach to print 50 unique ID numbers, while also letting me use the JQuery Ajax script. I hope this is clear, I don't know how else to describe what I want to do :D</p>