Note that there are some explanatory texts on larger screens.

plurals
  1. POPassing checkbox group values via jQuery
    text
    copied!<p>I am having one of those 'moments' where I am just confused.</p> <p>I have a form, with a checkbox group. There are 12 checkboxes. They are set up as follows:</p> <pre><code>&lt;input type="checkbox" id="search_shape1" name="search_shape[]" value="BR" /&gt; &lt;input type="checkbox" id="search_shape2" name="search_shape[]" value="AS" /&gt; </code></pre> <p>etc etc...</p> <p>Now, instead of submitting them via a submit button, I am using jQuery to pass all the form variables (this form also includes 5 jQuery.ui sliders. The code I am using is below:</p> <pre><code> $(function() { $("#epds").bind('submit',function() { var search_shape = $('#search_shape').val() || []; $.post('catalog/view/theme/emmaparker/template/information/db_query.php',{search_shape:search_shape}, function(data){ $("#search_results").html(data); }); return false; </code></pre> <p>The problem is, on my processing page (db_query.php), it NEVER gets the results of the checkbox. It does get all of the sliders inputs (input type=textbox.. I pulled all of those out of the above code). I have tried pretty much everything, and I am just confused. I have tried putting "search_shape" alone as the name, "search_shape[]" as the name, everything. It just won't pass a value. </p> <p>On the db_query page, I have tried outputting the value in several ways. I have tried print_r, simple echo, setting a value as an explicit array and then setting that variable to the post result, etc etc etc.</p> <p>I am at a loss. Can anyone smack me upside the head and let me know what I'm doing wrong? I'm sure it is something simple, like I am not passing the value in the jQuery properly or something.</p> <p>Thanks, Derek</p>
 

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