Answer the question
In order to leave comments, you need to log in
How to bind a select element to an input field?
Hello everyone, the question is, there are 3 selects (with a list of cars), and there is an input (field) where what should be displayed is what was selected in the select. Actually the question is how to implement it with jikveri?
Answer the question
In order to leave comments, you need to log in
well you can
<form action="#">
<select name='options'>
<option value='option-1'>Option 1</option>
<option value='option-2'>Option 2</option>
<option value='option-3'>Option 3</option>
</select>
<select name='options'>
<option value='option-1'>Option 1</option>
<option value='option-2'>Option 2</option>
<option value='option-3'>Option 3</option>
</select>
<select name='options'>
<option value='option-1'>Option 1</option>
<option value='option-2'>Option 2</option>
<option value='option-3'>Option 3</option>
</select>
<input type="text" />
</form>
;(function(w,$){
var selects = $('form').find('select'),
input = $('input');
selects.bind('change',function(e){
var string="";
for(var i =0,l=selects.length;i<l;i++){
string+=selects[i].value+" ";
}
input.val(string);
});
})(window,$);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question