How do I update the value in one text box (txtInterest%
) based on the value entered/changed in another text box (txtAmt
)?
This should work assuming txtAmt
and txtInterest%
are id
s 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())
});
});
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);
});