title: Limit checked , checkbox in bootstrap dataTable
body: <p>I have this code below to click a checkbox in my <code>DataTable</code> and get the <code>IDs</code> and store in an array. For Example I have a 2 seperate <code>DataTables</code> First is for President and second is for the Senators.</p>
  
  <p>We know that we can only vote 1 in President and for Senators we can choose many.</p>
  
  <p>My problem here is I can check how many checkboxes in the <code>DataTables</code>. How to limit the checked checkboxes?.</p>
  
  <blockquote>
    <p>Still learning in bootstrap here.</p>
  </blockquote>
  
  <p><strong>JS Code</strong></p>
  
  <pre><code>var dataTablestest = $("#tbltest").DataTable({
      responsive: true,
      processing: true,
      info: true,
      search: true,
      stateSave: true,
      order: [[1, "asc"], [2, "asc"]],
      lengthMenu: [[50, 100, 200, -1], [50, 100, 200, "All"]],
      ajax: { "url": "/Voting/LoadTableTest" },
  
      columns:
      [
           { data: "testID", title: "", visible: false, searchable: false },
          { data: "Fullname", title: "FullName", sClass: "alignRight" },
          { data: "Position", title: "Position", sClass: "alignRight" },
          { data: "party", title: "Party", sClass: "alignRight" },
          { data: "ActionMenu", title: "Click to vote", searchable: false, orderable: false, sClass: "alignCenter",
              "mRender": function (data) {
                  return '&lt;center&gt;&lt;label&gt;&lt;input class="checkId" type="checkbox" id="chkvote_' + data + '" value=""/&gt;&lt;/label&gt;&lt;/center&gt;';
              }
          }
      ]
  });
  var arrayIds = [];
  $('#tbltest tbody').on('click', 'tr', function (e) {
      if ($(e.target).is(".checkId")) {
          var Ids = dataTablestest.row(this).data().testID;
          arrayIds.push(Ids);
          return
      }
  });
  </code></pre>
  
  <p><strong>EDIT</strong></p>
  
  <p>I found an answer but there is a problem with it. My counter keeps increment every time I check a checkbox from my dataTable.</p>
  
  <pre><code> $('#tbltest tbody').on('click', 'tr', function (e) {
      if ($(e.target).is(".checkId")) {
          if ($(e.target).is(":checked") == true) {
              CheckCount = CheckCount + 1;
              var Ids = dataTablestest.row(this).data().testID;
              if (CheckCount &gt; 1) {
                  return false;
              }
              arrayIds.push(Ids);
              return
          }
          else {
              CheckCount = parseInt(CheckCount) - parseInt(1);
          }
      }
  });
  </code></pre>