Reputation: 1357
How do I update the value in one text box (txtInterest%
) based on the value entered/changed in another text box (txtAmt
)?
Upvotes: 11
Views: 41143
Reputation: 696
One more method for implementing this
$(document).ready(function(){
$('#txtAmt').keyup(function (){
$('#txtInterest%').val($('#txtAmt').val())
});
});
Upvotes: 4
Reputation: 3324
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);
});
Upvotes: 14
Reputation: 163228
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.
Upvotes: 4