title: how to condition data table checkbox if check/uncheck
body: <p>i dont know how to condition the checkbox inside the datatable. I want to condition if the checkbox in data table is check, i will insert it in my database, and if it is uncheck , i will delete it in database. I am using a codeigniter framework.</p>
  
  <p>Here is my controller:</p>
  
  <pre><code>public function getalldocs() {
          $listdocs = $this-&gt;Admin_model-&gt;getdoctors();
          $data = array();
          foreach ($listdocs as $docs) {
              $row = array();  
              $row[] = $docs-&gt;user_fname;
              $row[] = $docs-&gt;user_mname;
              $row[] = $docs-&gt;user_lname;
              $row[] = '&lt;input name="user_id[]" value="'.$docs-&gt;user_id.'" type="checkbox"&gt;';
  
              $data[] = $row;
          }
          $output = array(   
              "data" =&gt; $data,
          );
          echo json_encode($output);
      }
  </code></pre>
  
  <p>here is my javascript, i manage to alert the value of user_id when i click the checkbox but i dont know how to condition it, wether it was check or checked and uncheck again. Here it is:</p>
  
  <pre><code>function show_docs() {
      $("#dataTables-docs").dataTable().fnDestroy();
  
      table =  $('#dataTables-docs').DataTable({ 
        "ajax": {
                "url": "&lt;?php echo site_url('admin_controls/getalldocs')?&gt;",
                "type": "POST",
            },
            responsive: true,
            className: 'select-checkbox',
            'bInfo': false,
            'paging': false
        });
  }
  
  $('#dataTables-docs tbody').on('click', 'input[type="checkbox"]', function(e){
  
    var user_id = $(this).val();
    alert(user_id);
  
    });
  </code></pre>
  
  <p>Here is my view:</p>
  
  <pre><code> &lt;table id="dataTables-docs"  class="table table-striped table-bordered table-hover dataTable dtr-inline" role="grid" style="width: 100%;" width="100%" aria-describedby="dataTables-material"&gt;
                      &lt;thead&gt;
                          &lt;tr&gt; 
                              &lt;th&gt;First Name&lt;/th&gt;
                              &lt;th&gt;Middle Name&lt;/th&gt;
                              &lt;th&gt;Last Name&lt;/th&gt;                                               
                              &lt;th&gt;&lt;/th&gt;
                          &lt;/tr&gt;
                      &lt;/thead&gt;
                      &lt;tbody&gt;
      &lt;/tbody&gt;
  &lt;/table&gt;
  </code></pre>