I want to assign the multiple selected values to the different text field. If i selected four option assign values to the four different text field.
Html code
<select name="garden" multiple="multiple">
<option>Flowers</option>
<option>Shrubs</option>
<option>Trees</option>
<option>Bushes</option>
<option>Grass</option>
<option>Dirt</option>
</select>
<div></div>
<input type="text" id="opt1" />
<input type="text" id="opt2"/>
<input type="text" id="opt3" />
<input type="text" id="opt4" />
What i did sample jquery code
<script>
$( "select" )
.change(function() {
var str = "";
$( "select option:selected" ).each(function() {
str += $( this ).text() + " ";
});
$( "div" ).text( str );
});
})
.trigger( "change" );
</script>
Please anybody help this. Thanks for your corporation