textbox onchange event using jquery causes JScript runtime error: 'Deductions' is undefined

馋奶兔 提交于 2019-11-30 10:37:58

remove the OnChange handler

function Deductions() {


      var result = new Object();

      result.total = $("#Total").html();
      result.totalDeductions = $("#txtTotalDeductions").val();

      result.netTotal = result.total - result.totalDeductions;
      $('#NetTotal').html(result.netTotal);
  }

also wrap the code inside the ready handler and attach a change event handler

$(document).ready(function(){
 //attach with the id od deductions
$("#txtTotalDeductions").bind("change",Deductions);

});

Change your jScript to this, this will help :

$(function (){
    $('#txtTotalDeductions').change(function (){
      var total = $("#Total").html();
      var totalDeductions = $("#txtTotalDeductions").val();

      var netTotal = total - totalDeductions;
      $('#NetTotal').html(netTotal);

        });       

});

you can also use object. i have removed it for my convinience.

edit:

Remove your onchange event from textbox and also remove function deduction.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!