Note that there are some explanatory texts on larger screens.

plurals
  1. POJquery Ajax form with foreach php variable
    text
    copied!<p>I have a group of checkboxes with the same name and id, but have different variables that I want submitted with my jquery ajax form. The checkbox looks like this:</p> <pre><code>&lt;input class="checkbox" name="&lt;? echo"description_list[$i]";?&gt;" id="&lt;? echo"description_list[$i]";?&gt;" type="checkbox" value="&lt;? echo $row['description'];?&gt;" /&gt;&amp;nbsp;&lt;? echo $row['description'];?&gt;&lt;br /&gt; </code></pre> <p>and the call to jquery looks like this.</p> <pre><code>&lt;script type="text/javascript" &gt; $(document).ready(function() { $('.formSub').live('click',function() { var store = $("#store").val(); var type = $("#type").val(); var business_name=$("#business_name").val(); var first_name=$("#first_name").val(); var last_name=$("#last_name").val(); var phone = $("#phone").val(); var email = $("#email").val(); var make = $("#make").val(); var model = $("#model").val(); var esn = $("#esn").val(); var lock = $("#lock").val(); var description = $("#description").val(); var &lt;? echo"description_list[$i]";?&gt; = $("#&lt;? echo"description_list[$i]";?&gt;").val(); var dataString = 'store='+store+'&amp;type='+type+'&amp;business_name='+business_name+'&amp;phone='+phone+'&amp;email='+email+'&amp;make='+make+'&amp;model='+model+'&amp;esn='+esn+'&amp;lock='+lock+'&amp;description='+description+'&amp;&lt;? echo"description_list[$i]";?&gt;='+&lt;? echo"description_list[$i]";?&gt;; if(esn=='') { $('.error').show().fadeOut(3000); } else { $.ajax({ type: "POST", url: "somefile.php", data: dataString, success: function(response){ $('#customerInfo').slideUp(500); $('#repairResult').delay(500).slideDown(500); } }); } return false; }); }); &lt;/script&gt; </code></pre> <p>Not sure how to get it to do the loop on the foreach description[$i]... if someone could help would greatly appreciate.</p> <p>Thanks Andron... this is what I ended up with... works perfect.</p> <pre><code>&lt;script type="text/javascript"&gt; $(document).ready(function(){ $("#input_form").submit(function(){ var querystring = $(this).serialize(); $.post("submit.php", $(this).serialize()); $('#customerInfo').slideUp(500); $('#repairResult').delay(500).slideDown(500); return false; }); }); &lt;/script&gt; </code></pre>
 

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