I want to sum Textbox value with gridview column credit value as in image,i highlighted Credit total 5000 with textbox(txtamount).
<script type="text/javascript">
$(function () {
$(".js-example-placeholder-single").select2({
placeholder: "Select",
allowClear: true
});
});
//On UpdatePanel Refresh
var prm = Sys.WebForms.PageRequestManager.getInstance();
if (prm != null) {
prm.add_endRequest(function (sender, e) {
if (sender._postBackSettings.panelsToUpdate != null) {
$(".js-example-placeholder-single").select2({
placeholder: "Select",
allowClear: true
});
$(function () {
CalculateDebitCredittotal()
});
}
});
};
$(function () {
CalculateDebitCredittotal()
});
function CalculateDebitCredittotal() {
var creditTotal = 0;
var debitTotal = 0;
$("[id*=gvtrans] tr:has(td)").each(function () {
if ($(this).find($("[id*=txtCredit]")).val() != "" && $(this).find($("[id*=txtCredit]")).val() != undefined)
{
creditTotal += parseFloat($(this).find($("[id*=txtCredit]")).val());
}
if ($(this).find($("[id*=txtDebit]")).val() != "" && $(this).find($("[id*=txtDebit]")).val() != undefined)
{
debitTotal += parseFloat($(this).find($("[id*=txtDebit]")).val());
}
$(this).find($("[id*=lblTotaldr]")).html("Total:" + debitTotal.toString());
$(this).find($("[id*=lblTotalcr]")).html("Total:" + creditTotal.toString() );
});
$("[id*=hfCredit]").val(creditTotal);
$("[id*=hfDebit]").val(debitTotal);
}
</script>