I have some custom Jquery which grabs the id's from a select list, and populates a secondary select list with those that are selected.
I have this working well, however I need the secondary select list needs to display the text value of the selected option. Currently I just get the actual id.
Can anybody assist please?
JQUERY
$('#myselect').change(function() {
var row = $(".chosen-select").val();
$('#secondSelect').html('');
jQuery.each(row, function(i, val) {
$('#secondSelect').append('<option value=' + val + '>' + val) + '</option>';
});
});
HTML
First select list
<select data-placeholder="Choose cars..." class="chosen-select" name="myselect[]" id="myselect" multiple>
<option value="1">Vauxhall</option>
<option value="2">Volvo</option>
etc...
</select>
Second select list
<select name="secondSelect" id="secondSelect">
<option value="">Select Model</option>
should be populated here..
</select>