title: How to get ids of all checked checkbox on button click using jQuery
body: <pre><code>&lt;html&gt;  
      &lt;input type='checkbox' id='1' name='checkMr[]' value='1' /&gt;       
      &lt;input type='checkbox' id='2' name='checkMr[]' value='2' /&gt;            
      &lt;input type='checkbox' id='3' name='checkMr[]' value='3' /&gt;         
      &lt;input type='checkbox' id='4' name='checkMr[]' value='4' /&gt;        
  
      &lt;a id="savedoctorschedule" style="float: right;" class="clyes clbutton clbtnSave"&gt;Save&lt;/a&gt;       
  &lt;/html&gt; 
  
  &lt;script&gt;
  $j("#savedoctorschedule").bind("click", function () { 
      $j.ajax({
          url: "schedulemr.php",
          type: "post",
          data: { schmrid: $j("#sel_mr").val(), 
          schedocid: $j("#checkMr[]").val(), 
          schedate: $j("#date1").val(), },
          success:function(response){         
          }
  &lt;/script&gt;
  
  &lt;?php
  include '../includes/include.php';
  $schmrid = $_POST['sel_mr'];
  $schedate = $_POST['date1'];
  $schedocid = $_POST['checkMr'];
  foreach($schedocid as $a =&gt; $b)
  {
     $sql="INSERT INTO tbl_mr_schedule(doctor_idscheduled_date) 
     VALUES ('".$schedocid[$a]."','".$schmrid."','0','".$date."','".$schedate."');";
     mysql_query($sql) or die(mysql_error());
  }
  header('Location:../visitplan/');
  ?&gt;
  </code></pre>
  
  <p>I want all the ids of checked checkboxes using jQuery; the checkbox may be <code>n</code> number. I want to insert the checked checkboxes' value in the database where the number of records will depend upon the number of checked checkbox. This would be using PHP as server-side script. </p>
  
  <p>How can I fix it?</p>