<select id="paymenttype">
<option value="">---Select---</option>
<option>100</option>
<option>200</option>
<option>300</option>
<option>400</option>
<option>500</option>
</select>
<input type="text" id="check" value="" readonly/>
<input type="text" id="update" value="" />
JS
$("#paymenttype").change(function(){
$("#check").val($('#paymenttype option:selected').text());
});
$("#check").change(function(){
alert("soul");
$("#update").val(0);
});
Jsfiddle code example
As shown in the code $("#check").change(function() it doesn't work? what function should i use in order to Jquery work? when there is change in the input text box check i am going to add? this is just an example
You just need to manually fire the change event when you set the value:
$("#paymenttype").change(function(){
$("#check").val($('#paymenttype option:selected').text()).change(); // <-- HERE
});
http://jsfiddle.net/infernalbadger/e6yEd/7/
You could add a tiny plugin so you can set the value and fire the change event at the same time in a single call.
This way you just call $("#check").changeVal($('#paymenttype option:selected').text());:
(function($) {
$.fn.changeVal = function(value) {
return this.val(value).change();
};
})(jQuery);
http://jsfiddle.net/infernalbadger/e6yEd/11/
Try adding the trigger
$("#paymenttype").change(function(){
$("#check").val($('#paymenttype option:selected').text()).change();
});
note the .change() at the end of the second line
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With