예 가능합니다.
원하는대로 onchange 이벤트 처리기를 추가하십시오.
<select class="required" id="thechoices" onchange="return airportChoice(this)">
숨기려는 상자 ID에 대한 표시를 숨김으로 설정합니다.
#box1{display:none} //css
여기에 easly 당신이 더 많은 선택을해야 할 경우 당신의 선택의 각 아래의 추가 공항 선택에서까지 많이 가질 수 있도록 질문을 바탕으로 기준에 따라 인수를 recives 일반적인 기능이다.
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