Reputation: 111
Here is my code:
<select name="art_type">
<option value="ra">Research Article</option>
<option value="rea">Review Article</option>
<option value="re">Reviews</option>
<option value="op">Opinions</option>
<option value="le">Letters to the Editor</option>
</select>
<input style="border: none;" type="text" id="get_id_val" value="">
So whatever value user selects from the select box that value should be entered in the textbox. How to do that?
Upvotes: 2
Views: 4700
Reputation: 28845
Try this:
$('select[name=art_type]').on('change', function () {
var select = $(this).find('option:selected').val()
$('#get_id_val').val(select)
});
Upvotes: 1
Reputation: 8225
$("select").on("change", function(){
$("#get_id_val").val( this.options[this.selectedIndex].value );
});
Upvotes: 1
Reputation: 388446
Try
jQuery(function($){
var $idval = $('#get_id_val');
$('select[name="art_type"]').change(function(){
$idval.val($(this).val())
}).triggerHandler('change')
})
Demo: Fiddle
Upvotes: 1