Denmark Puso

Denmark Puso

  • NA
  • 232
  • 50.7k

how to diselect checkbox after alert?

Nov 27 2020 2:43 AM
im using datatable i need to limit the selected row. how can i diselect my last selected after alert?
 
  1. $(function () {  
  2.            var TableExcess = $('#PaymentExcess').DataTable({  
  3.                 "scrollY"'50vh',  
  4.                 "scrollCollapse"true,  
  5.                 "paging"false,  
  6.                 "destroy"true,  
  7.                 "ajax""@Url.Action("GetPaymentExcess", "payable")",  
  8.                 "columns": [  
  9.                     {  
  10.                         "render"function (data, type, full, meta) {  
  11.                             return "<input type='checkbox' class='checkbox' onclick='addavailable(" + full.Id + ", " + full.AvailableAmount + ", \"" + full.AccountName + "\", this.checked)'>"  
  12.                         }  
  13.                     },  
  14.                     { "data""Id" },  
  15.                     { "data""AccountName" },  
  16.                     { "data""PaidAmount" },  
  17.                     { "data""AvailableAmount" },  
  18.                 ]  
  19.            });  
  20.         });  
  21.   
  22.  var idsExcess = [];  
  23.   
  24.  function addavailable(id, amount, acctname, isChecked)  
  25.         {  
  26.             if (isChecked) {  
  27.                 //condition  
  28.                  idsExcess.push(id);  
  29.                  if(idsExcess.lenght > 2) {  
  30.                     var i = idsExcess.indexOf(id);  
  31.                     idsExcess.splice(i, 1);  
  32.                     alert("diselect last selected");  
  33.                     isChecked = false;  
  34.                  }  
  35.   
  36.             }  
  37.             else {  
  38.                  var i = idsExcess.indexOf(id);  
  39.                 idsExcess.splice(i, 1);  
  40.             }  
  41.         }  
 

Answers (2)