title: How to Pass Multiple CheckBox values through AJAX and process them?|
body: <p>Good evening guys,</p>
  
  <p>I'm trying to pass multiple checkbox values through AJAX and process them with a external .php script. Goal: delete multiple rows using checkboxes without refreshing the page.</p>
  
  <p>Please assist me with passing the selected checkboxes into the datastring and putting them in the mysql command in the external .php file. This is the code so far:</p>
  
  <p>The checkboxes:</p>
  
  <pre><code>&lt;form name="frmMain" id="myForm" method="post" OnSubmit="return onDelete();"&gt;
  
  
  &lt;input class="checkbox_button_del" type="submit" id="buttondel" value="Delete" /&gt; // submit to ajax
  
  
  &lt;input type="checkbox" class="cb-element" name="chkDel[]" id="chkDel&lt;?=$i;?&gt;" value="' .($id). '"&gt;
  
  
  &lt;input type="hidden" name="hdnCount" value="&lt;?=$i;?&gt;"&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>The AJAX:</p>
  
  <pre><code>$(function () {
      $(".checkbox_button_del").click(function () {
          var id = $(this).attr("id");
          var dataString = 'id=' + id; //pass checkbox ids somehow
          var parent = $(this).parents('tr:first');
  
  
          $.ajax({
              type: "POST",
              url: "core/actions/delete_multiple.php",
              data: dataString,
              cache: false,
  
              success: function () {
                  parent.fadeOut('300', function () {
                      $(this).remove();
                  });
                  $("#display").load("display.php")
  
              }
          });
  
          return false;
      });
  });   
  </code></pre>
  
  <p>The delete script:</p>
  
  <pre><code>// receive checkbox ids from ajax and delete rows
  
      for($i=0;$i&lt;count($_POST["chkDel"]);$i++)
      {
          if($_POST["chkDel"][$i] != "")
          {
              $strSQL = "DELETE FROM players ";
              $strSQL .="WHERE id = '".$_POST["chkDel"][$i]."' ";
              $objQuery = mysql_query($strSQL);
          }
      }
  </code></pre>