Denmark Puso

Denmark Puso

  • NA
  • 232
  • 50.3k

how can i change the value of textbox using function?

May 22 2020 2:10 AM
i need to subtract the amount when i click the checkbox. but my textbox amount didnot change the value inputed. when ill try to alert the total the value is show correct. how can i change the value of textbox amount when i click checkbox. thanks
 
  1. @Html.LabelFor(x => x.Amount, new { @class = "form-label" })  
  2. @Html.TextBoxFor(x => x.Amount, new { @class = "form-control", @id = "Amount" })  
  1. $(function () {  
  2.        $('#Payable').DataTable({  
  3.            "ajax""@Url.Action("getpayablelist", "payment")",  
  4.                 "columns": [  
  5.                    {  
  6.                        "render"function (data, type, full, meta) {  
  7.                           return "<input type='checkbox' class='checkbox' onclick='add(" + full.Id + ", " + full.Amount + ", this.checked)'>"  
  8.                        }  
  9.                    },  
  10.                    { "data""Type" },  
  11.                    { "data""ReferenceNo" },  
  12.                    { "data""Amount" }  
  13.                 ]  
  14.        });  
  15.    });  
  16.   
  17. ar ids = [];  
  18.    function add(id, amount, isChecked) {  
  19.        var total = $('#Amount').val();  
  20.        if (isChecked) {  
  21.            ids.push(id);  
  22.            total = total - amount;  
  23.            alert(total);  
  24.        }  
  25.        else {  
  26.            var i = ids.indexOf(id);  
  27.            ids.splice(i, 1);  
  28.        }  
  29.    }  
 
 
 
 
 

Answers (1)