Search Results

Search found 1 results on 1 pages for 'user557563'.

Page 1/1 | 1 

  • jQuery, Ajax & PHP submit multiple forms dilemma

    - by user557563
    This is a very simple form that I have found on the web (as I am a jQuery beginner). <!-- this is my jquery --> <script> $(document).ready(function(){ $("form#submit_wall").submit(function() { var message_wall = $('#message_wall').attr('value'); var id = $('#id').attr('value'); $.ajax({ type: "POST", url: "index.php?leht=pildid", data:"message_wall="+ message_wall + "&id="+ id, cache: false, success: function(){ $("ul#wall").prepend(""+message_wall+"", ""+id+""); $("ul#wall li:first").fadeIn(); alert("Thank you for your comment!"); } }); return false; }); }); </script> <!-- this is my HTML+PHP --> some PHP ... while($row_pilt = mysql_fetch_assoc($select_pilt)){ print <form id="submit_wall"> <label for="message_wall">Share your message on the Wall</label> <input type="text" id="message_wall" /> <input type="hidden" id="id" value="'.(int)$row_pilt['id'].'"> <button type="submit">Post to wall</button> </form> and down below is my PHP script that writes to mySQL. It is a pretty straight forward script. However, it is getting little complicated when I submit it. Since I have more than one form on my page (per WHILE PHP LOOP), thus when I submit - only the FIRST form gets submitted. Furthermore, any other subsequent forms that I submit - data is being copied from the first form. Is there any jQuery functions that clear the data? - or is there a better solution. Thanks, Nick

    Read the article

1