title: Getting values from php dynamically created checkboxes with jquery
body: <p>This is not a duplicate of a question suggested as duplicate as this question has nothing to do with event binding</p>
  
  <p>Hi, Im trying to get the value of a check box to send in a ajax request to a php page, the checkboxes are dynamically created using php. So far my code allows me to show an instruction to the user telling the user to choose an admin to delete from the list dynamically created. Then when a checkbox is checked the instrcution hides and the delete admin button is shown. Next on clicking the delete button I'm trying to confirm the user wants to delete the admin chosen and click to confirm or cancel. The real problem I'having is getting the value of the chosen checked checkbox to pass to the php processing page, so far I have managed to get the value of the first checkbox to pass no matter which checkbox is checked</p>
  
  <p><strong>Jquery</strong></p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  
  $(document).ready(function() {
  
      var checkboxes = $("input[type='checkbox']");
  
  checkboxes.click(function() {
      $('.delete_admin_but').show();
      $('#adminDeleteNotice').hide();
      var deleteAdminName=$(this).attr('id');
  });
  
      $(".delete_admin_but").click(function() {
  
  
  
  //  if(confirm("Are you sure you want to delete the Admin")) {
  
      $("#deleteAdminError").html('&lt;img src="image/ajax-loader.gif" width="16" height="16" alt=""/&gt;');
  
  
  
  
  $.post("includes/delete_admin.inc.php",{deleteAdminname:deleteAdminName},function(json)   {
      if(json.result === "success") {
          $("#deleteAdminError").html(json.message);
  //  $('.add_intern').get(0).reset();
      }else{
          $("#deleteAdminError").html(json.message);
      }
  });
  
  
  
  });//submit click
  });//doc ready
  &lt;/script&gt;
  </code></pre>
  
  <p><strong>html form</strong></p>
  
  <pre><code>&lt;div id="deleteAdmin" style="display:none"&gt;
  
  &lt;form id="adminDelete"&gt;
  
            &lt;div class="delete_admin_list"&gt;
  
              &lt;?php while($row = mysqli_fetch_array($result1)) { ?&gt;
  
                &lt;input type="checkbox" id="&lt;?php echo $row['name']; ?&gt;" value="&lt;?php echo $row['id']; ?&gt;" name="delete[]" class="checkboxAdmin" /&gt;
  
                &lt;div id="admin_db_detail"&gt;&lt;?php echo $row['name']; ?&gt; - &lt;?php echo $row['email']; ?&gt;&lt;/div&gt;
  
                &lt;?php } ?&gt;
  
        &lt;/div&gt;        
  
  
  &lt;div id="adminDeleteNotice" style="display:block"&gt;Please Choose an Admin to Delete&lt;/div&gt;
  
  &lt;input name="delete_admin_but" id="delete_admin_but" type="button" class="delete_admin_but" value="Delete Admin" style="display:none"/&gt;
  
  &lt;/form&gt;
  
  &lt;div id="deleteAdminError"&gt;&lt;/div&gt;
  
  &lt;/div&gt;
  </code></pre>
  
  <p>If anyone could help me figure this out I would be greatful</p>