How to update the value in one text box based on the value entered in another text box?

后端 未结 3 1964
深忆病人
深忆病人 2020-12-19 00:36

How do I update the value in one text box (txtInterest%) based on the value entered/changed in another text box (txtAmt)?

相关标签:
3条回答
  • 2020-12-19 00:57

    This should work assuming txtAmt and txtInterest% are ids on your page:

    $(function() {
        $('#txtAmt').change(function() {
           $('#txtInterest%').val(this.value);
        });
    });
    

    See jQuery's change event handler.

    0 讨论(0)
  • 2020-12-19 01:19

    One more method for implementing this

    $(document).ready(function(){
          $('#txtAmt').keyup(function (){
           $('#txtInterest%').val($('#txtAmt').val())
        });
        });
    
    0 讨论(0)
  • 2020-12-19 01:23

    Use jQuery's change method for updating. Using your example:

    $('#txtAmt').change(function() {
      //get txtAmt value  
      var txtAmtval = $('#txtAmt').val();
      //change txtInterest% value
      $('#txtInterest%').val(txtAmtval);
    });
    
    0 讨论(0)
提交回复
热议问题