Plain Javascript Delete Item From Drop Down Select
If you want to avoid the duplicate selection in the both lists you could use :
functionshow_all(select_name){
var second_options = document.querySelectorAll("#"+select_name+" option");
for(var i=0;i<second_options.length;i++){
second_options[i].style.display="block";
}
}
document.getElementById("first").addEventListener("change", function() {
show_all("second");
document.querySelector("#second option[value='"+this.value+"']").style.display="none";
})
document.getElementById("second").addEventListener("change", function() {
show_all("first");
document.querySelector("#first option[value='"+this.value+"']").style.display="none";
})
<selectclass='form-dropdown'name='first'id='first'><optionvalue='none'selected>No Choice</option><optionvalue='Workshop 1'> Workshop 1 </option><optionvalue='Workshop 2'> Workshop 2 </option><optionvalue='Workshop 3'> Workshop 3 </option><optionvalue='Workshop 4'> Workshop 4 </option><optionvalue='Workshop 5'> Workshop 5 </option></select><selectclass='form-dropdown'name='second'id='second'><optionvalue='none'selected>No Choice</option><optionvalue='Workshop 1'> Workshop 1 </option><optionvalue='Workshop 2'> Workshop 2 </option><optionvalue='Workshop 3'> Workshop 3 </option><optionvalue='Workshop 4'> Workshop 4 </option><optionvalue='Workshop 5'> Workshop 5 </option></select>
Post a Comment for "Plain Javascript Delete Item From Drop Down Select"