Getting value from HTML select tag

I have html combo / select. When the user selects an item, I want to fill it with a textboxcontrol. How to do it.

+2


source to share


1 answer


HTML:

<select id="combobox">
     <option value="">Pick one</option>
     <option value="1">1</option>
     <option value="2">2</option>
     <option value="3">3</option>
     <option value="4">4</option>
</select>
<input id="textbox" type="text" />

      



Javascript (assumes jQuery):

$('#combobox').change( function(){
     $('#textbox').val( $(this).val() );
}).click( function(){
     $('#textbox').val( $(this).val() );
});

      

+3


source







All Articles