Reputation: 41
Please help me. I need to change a textbox value when i give value in another textbox. see i have three text box first one is Qty another Amount and third will be a Total Amount. here i will give a value for Qty and amount. Now third textbox i mean Total amount will be appear automatically.
Please help me...
Upvotes: 2
Views: 150
Reputation: 39902
You use the change
event to monitor your first two inputs. Then you use the val
method to get and set the property values.
$('#qty, #amount').change( function(){
var total = $('#qty').val() * $('#amount').val();
$('#total').val(total);
});
Upvotes: 1
Reputation: 5247
HTML5 has an oninput
event that would serve this purpose. You'd need to use events like onfocus
, onkeypress
and onblur
in conjunction to achieve a similar level of responsiveness in older browsers, though. Or, if it's not essential that these values be updated with every keystroke, you can simply use the onchange
event to update the value whenever the user changes, then blurs the textbox.
Upvotes: 0