I have the following code
function searchFlights() {
var select1 = document.getElementById(\"airports-select-1\");
var selected1 = [];
while(select1
Wouldn't this do it:
function searchFlights() {
var select1 = document.getElementById("airports-select-1");
var selected1 = [];
for (var i = 0; i < select1.length; i++) {
if (select1.options[i].selected) selected1.push(select1.options[i].value);
}
console.log(selected1);
}
function searchFlights() {
var select1 = document.getElementById("airports-select-1");
var selected1 = [];
for (var i = 0; i < select1.length; i++) {
if (select1.options[i].selected) selected1.push(select1.options[i].value);
}
console.log(selected1);
}
jsFiddle example