Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery, Ajax & PHP submit multiple forms dilemma
    primarykey
    data
    text
    <h2> This is a very simple form that I have found on the web (as I am a jQuery beginner).</h2> <pre><code>&lt;!-- this is my jquery --&gt; &lt;script&gt; $(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 + "&amp;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; }); }); &lt;/script&gt; &lt;!-- this is my HTML+PHP --&gt; some PHP ... while($row_pilt = mysql_fetch_assoc($select_pilt)){ print &lt;form id="submit_wall"&gt; &lt;label for="message_wall"&gt;Share your message on the Wall&lt;/label&gt; &lt;input type="text" id="message_wall" /&gt; &lt;input type="hidden" id="id" value="'.(int)$row_pilt['id'].'"&gt; &lt;button type="submit"&gt;Post to wall&lt;/button&gt; &lt;/form&gt; </code></pre> <blockquote> <p>and down below is my PHP script that writes to mySQL.</p> </blockquote> <p>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.</p> <p>Thanks, Nick</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload