Add two textbox values and display the sum in a third textbox automatically

后端 未结 8 2051
一整个雨季
一整个雨季 2020-12-18 00:43

I have assigned a task to add two textbox values.I want the result of addition to appear in the 3rd textbox,as soon as enter the values in the first two textboxes,without pr

8条回答
  •  没有蜡笔的小新
    2020-12-18 01:06

    This is the correct code

    function sum() 
    { 
        var txtFirstNumberValue = document.getElementById('total_fees').value; 
        var txtSecondNumberValue = document.getElementById('advance_payement').value; 
        var result = parseInt(txtFirstNumberValue) - parseInt(txtSecondNumberValue); 
        if(txtFirstNumberValue=="" ||txtSecondNumberValue=="") 
        { 
            document.getElementById('balance_payement').value = 0; 
        }
        if (!isNaN(result)) 
        { 
            document.getElementById('balance_payement').value = result;
        }
    } 
    

提交回复
热议问题