title: Php and javascript submiting form with changing form name?
body: <p>Hi there i am working on one php java submithing comment system and now i have a problem which i can not solve alone.
  I just want to ask how i can make this</p>
  
  <pre><code>$('#addCommentForm'+x).submit(function(e){
  
  DO something here
  }
  </code></pre>
  
  <p>addCommentForm has many numbers after it like this: addCommentForm1 addCommentForm2 addCommentForm3 addCommentForm4 and rising. So how i can make this dinamicly changing name to work submithing in java ?</p>
  
  <pre><code>var x = $_POST['comentonpost'];
  </code></pre>
  
  <p>The $_POST is coming from here:</p>
  
  <pre><code>&lt;script type='text/javascript'&gt; var $_POST = &lt;?php echo !empty($_POST)?json_encode($_POST):'null';?&gt;; &lt;/script&gt;
  </code></pre>
  
  <p>X - is post value that i am getting from HTML form for submiting the info but if i press once submit on one comment the javascript is working only for this comment until the page is refreshed.<br>
  Here you can see --- <a href="http://www.youtube.com/watch?v=okqQsPCZqVE" rel="nofollow">http://www.youtube.com/watch?v=okqQsPCZqVE</a></p>
  
  <p>Here is the whole java script:</p>
  
  <pre><code>$(document).ready(function(){
  
  var x = $_POST['comentonpost'];
  /* The following code is executed once the DOM is loaded */
  
  /* This flag will prevent multiple comment submits: */
  var working = false;
  
  /* Listening for the submit event of the form: */
  $('#addCommentForm'+x).submit(function(e){
  
      e.preventDefault();
      if(working) return false;
  
      working = true;
      $('#submit').val('Working..');
      $('span.error').remove();
  
      /* Sending the form fileds to submit.php: */
      $.post('comment.submit.php',$(this).serialize(),function(msg){
  
          working = false;
          $('#submit').val('Submit');
  
  
              /* 
              /   If the insert was successful, add the comment
              /   below the last one on the page with a slideDown effect
              /*/
  
              $(msg.html).hide().insertBefore('#addCommentContainer'+x).slideDown();
  
  
      },'json');
  
  });
  
  });
  </code></pre>
  
  <p>So please tell me how can i fix that and make this script working well without refreshing the page?</p>