title: multi form ajax php social comment system
body: <p>I have a lot of these forms that I post with PHP. They are under every article in my page, but when I submit the form with these ajax functions it only sends to the first form of the page. Why? I want send these form separately what am I doing wrong?</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>    &lt;script type="text/javascript" &gt;
      $(function() {
      $(".submit").click(function() 
      {
      var name = $("#name").val();
      var comment = $("#comment").val();
      var post_id = $("#post").val(); 
      var dataString = 'name='+ name  + '&amp;comment=' + comment+ '&amp;post_id=' + post_id;
      if(name==''  || comment=='')
      {
      alert('Please Give Valid Details');
      }
      else
      {
      $("#flash").show();
      $("#flash").fadeIn(400).html('&lt;img src="images/loading.gif" /&gt;Loading Comment...');
      $.ajax({
      type: "POST",
      url: "commenti.php",
      data: dataString,
      cache: false,
      success: function(html){
      $("ol#update").append(html);
      $("ol#update li:last").fadeIn("slow");
      $("#flash").hide();
      }
      });
      }return false;
      });
      });   
  &lt;script&gt;</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code> &lt;ol id="update" class="timeline"&gt;
  &lt;/ol&gt;
      &lt;div id="flash"&gt;&lt;/div&gt;
      &lt;div &gt;
      &lt;form action="#" method="post"&gt;
      &lt;input type="hidden" id="post" value="&lt;?php echo $post_id; ?&gt;"/&gt;
      &lt;input type="hidden" id="name" value="&lt;?php echo $username; ?&gt;"/&gt; 
      &lt;textarea id="comment"&gt;&lt;/textarea&gt;&lt;br /&gt;
      &lt;input type="submit" class="submit" value=" Submit Comment " /&gt;
      &lt;/form&gt;
      &lt;/div&gt;
  
   &lt;ol id="update" class="timeline"&gt;
  &lt;/ol&gt;
      &lt;div id="flash"&gt;&lt;/div&gt;
      &lt;div &gt;
      &lt;form action="#" method="post"&gt;
      &lt;input type="hidden" id="post" value="&lt;?php echo $post_id; ?&gt;"/&gt;
      &lt;input type="hidden" id="name" value="&lt;?php echo $username; ?&gt;"/&gt; 
      &lt;textarea id="comment"&gt;&lt;/textarea&gt;&lt;br /&gt;
      &lt;input type="submit" class="submit" value=" Submit Comment " /&gt;
      &lt;/form&gt;
      &lt;/div&gt;
  
   &lt;ol id="update" class="timeline"&gt;
  &lt;/ol&gt;
      &lt;div id="flash"&gt;&lt;/div&gt;
      &lt;div &gt;
      &lt;form action="#" method="post"&gt;
      &lt;input type="hidden" id="post" value="&lt;?php echo $post_id; ?&gt;"/&gt;
      &lt;input type="hidden" id="name" value="&lt;?php echo $username; ?&gt;"/&gt; 
      &lt;textarea id="comment"&gt;&lt;/textarea&gt;&lt;br /&gt;
      &lt;input type="submit" class="submit" value=" Submit Comment " /&gt;
      &lt;/form&gt;
      &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>