How can I retrieve the value of several dropdowns (only those filled in)
The function below does not work correctly. For example, if I select only the second combo has output: , 2 He takes the void as if it were a selection. Can you work around this?
$("div.container-fluid").on("change", "select.dropDown", function() {
var selectData = [];
$('select.dropDown option:selected').each(function(i, selected){
var selectData[i] = $(selected).val();
});
});
My html looks like this:
<select class="dropDown" id="column_1">
<option value="" selected="" disabled="">Please select</option>
<option value="1">A</option>
<option value="2">B</option>
<option value="3">C</option>
<option value="4">D</option>
</select>
<select class="dropDown" id="column_2">
<option value="" selected="" disabled="">Please select</option>
<option value="1">A</option>
<option value="2">B</option>
<option value="3">C</option>
<option value="4">D</option>
</select>