Reputation: 7409
Like an airline website.
When you select the departure airport.
the content of arrival airport will be changed correspondinly.
For examle, if you choose Paris at departure airport. Then, Paris should not appear in the arrival airport.
How could I do this, any keyword or term to search for further information ?
Thanks
Upvotes: 1
Views: 80
Reputation: 9550
Check working demo: JSFiddle
Use jQuery selector to find the destination options element, iterate to hide the one targeted:
function changeDestination(target) {
var options = $('#destination option');
for (var i = 0; i < options.length; i++) {
var opt = $(options[i]);
opt.show();
if (opt.attr('name') === target.value) {
opt.hide();
}
}
}
Upvotes: 2
Reputation: 1503
This is how you dynamically add an Option to a select....
var x = document.getElementById("selectid");
var option = document.createElement("option");
option.text = "newOption";
x.add(option);
There is also a remove() method you can employ.
I think a combination of those will get done what you need to get done. Google "add option to select javascript" and "remove option from select javascript" and i think you will be on your way.
Upvotes: 0