开发者

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

开发者 https://www.devze.com 2023-02-02 01:44 出处:网络
How do I updat开发者_开发技巧e the value in one text box (txtInterest%) based on the value entered/changed in another text box (txtAmt)?Use jQuery\'s change method for updating. Using your example:

How do I updat开发者_开发技巧e the value in one text box (txtInterest%) based on the value entered/changed in another text box (txtAmt)?


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);
});


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.


One more method for implementing this

$(document).ready(function(){
      $('#txtAmt').keyup(function (){
       $('#txtInterest%').val($('#txtAmt').val())
    });
    });
0

精彩评论

暂无评论...
验证码 换一张
取 消