Reputation: 327
here is my code.
<form action="demo_form.asp">
First name: <input type="text" name="fname" id="fname"><br>
Last name: <input type="text" name="lname" id="lname"><br>
<input type="submit" value="Submit">
</form>
Javascript:
$(document).ready(function() {
$('#cash_received').change(function () {
$("#lname").val("mytest");
}
});
});
It does not set the value mytest in the Last Name text box.
Upvotes: 1
Views: 79
Reputation: 34107
Demo http://jsfiddle.net/VAcKN/
few things jsut as idea: (these are mere ideas yo) :)
PSL nailed it anyways!
.keyPress
.input
and chuck in value=""
Code
$(document).ready(function () {
$('#fname').change(function () {
$("#lname").val("mytest");
});
});
Upvotes: 3
Reputation: 123739
That is because you have a syntax error in your script and of course your event did not get registered because of that.
$(document).ready(function () {
$('#cash_received').change(function () {
$("#lname").val("mytest");
} //<-- Remove this
});
});
Always look at your browser console for any errors, you can catch up all the syntax errors then and there itself
Upvotes: 4