是有可能
添加onchange事件处理程序到你的选择。
<select class="required" id="thechoices" onchange="return airportChoice(this)">
设置要隐藏隐藏式接线盒ID的显示。
#box1{display:none} //css
这是一个泛型函数基于引用,收到
的说法,根据您的问题,所以你可以伊斯利有很多到从机场选择只需添加以下到您的每个选择,如果你需要更多的选择。
onchange="return airportChoice(this)"
JS功能
function airportChoice(n){
if(n.selectedIndex === 1){
// show a div (id) // alert(n.value);
document.getElementById(n.value).style.display = "block";
}else if(n.selectedIndex === 2){
location.href= n.value; // redirect the user to the url
}
// this last one is not what you ask but for completeness
// hide the box div if the first option is selected again
else if (n.selectedIndex == 0){ // alert(n[1].value);
document.getElementById(n[1].value).style.display = "none";
}
}
将你永远只能有两种选择,喜欢“从机场”和“到机场”的选择? – david