I have the following code
function searchFlights() {
var select1 = document.getElementById("airports-select-1");
var selected1 = [];
while(select1.selectedIndex != -1) {
if(select1.selectedIndex != 0) selected1.push(select1.options[select1.selectedIndex].value);
select1.options[select1.selectedIndex].selected = false;
}
console.log(selected1);
}
This works right, but as you can see from the code this line:
select1.options[select1.selectedIndex].selected = false;
Is doing a deselecting of the value.
Now, I do not want to deselect the values. If I uncomment that line in the code, the code will run forever.
Is there any more refined and sophisticated solution for retrieving multiple values from a select tag using Javascript?