JSFiddle - React, Tailwind, and code Playground
by David Thomas
HTML
<form action="#" method="post">
<select name="departure" size="1">
<option value="1">NY</option>
<option value="2">FL</option>
<option value="3">LA</option>
</select>
<select name="arrival" size="1">
<option value="1">NY</option>
<option value="2">FL</option>
<option value="3">LA</option>
</select>
</form>
JavaScript
function deDupe(el) {
var opt = el.selectedIndex,
other = el.name == 'departure' ? document.getElementsByName('arrival')[0] : document.getElementsByName('departure')[0],
options = other.getElementsByTagName('option');
for (var i = 0, len = options.length; i < len; i++) {
options[i].disabled = i == opt ? true : false;
}
}
var departure = document.getElementsByName('departure')[0],
arrival = document.getElementsByName('arrival')[0];
deDupe(document.getElementsByName('departure')[0]);
departure.onchange = function () {
deDupe(departure);
};
arrival.onchange = function () {
deDupe(arrival);
};