How to update the value in one text box based on the value entered in another text box?
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 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())
});
});
精彩评论