javascript Onchange

发布于 2024-12-18 20:40:08 字数 579 浏览 5 评论 0原文

我有两个下拉列表,一个用于接送位置,另一个用于下车位置。两者的选项都是

泽西机场
泽西港
泽西岛酒店
根西岛机场
根西岛港
根西岛酒店

当我选择在根西岛接载时,当他们去下车时,泽西岛不会 出现...

function test(val){
    alert(val);
    if(val == 'Jersey Airport' || val == 'Jersey Harbour' || val == 'Jersey Hotel'){                 
      //                  
    }else if(val == 'Guernsey Airport' || val == 'Guernsey Harbour' || val == 'Guernsey Hotel'){                    
        //                    
    }else{

    }
}

如何使用 JavaScript 来做到这一点?

I've two dropdown lists one for pick up location and other for drop off location. Options in both are

Jersey Airport

Jersey Harbour

Jersey Hotel

Guernsey Airport

Guernsey Harbour

Guernsey Hotel

When I select the pick up in Guernsey, when they went to the drop off, Jersey would not
appear...

function test(val){
    alert(val);
    if(val == 'Jersey Airport' || val == 'Jersey Harbour' || val == 'Jersey Hotel'){                 
      //                  
    }else if(val == 'Guernsey Airport' || val == 'Guernsey Harbour' || val == 'Guernsey Hotel'){                    
        //                    
    }else{

    }
}

How to do it using JavaScript?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

把人绕傻吧 2024-12-25 20:40:08

这里没有太多信息可以继续,很高兴看到您的选择 html。

然而我注意到的一件事是你的 if 和 else if 是相同的,你的意图是否是做类似的事情:

function test(val){
     alert(val);
     if(val == 'Jersey Airport' || val == 'Jersey Harbour' || val == 'Jersey Hotel'){
          //                  
     }else if(val == 'Guernsey Airport' || val == 'Guernsey Harbour' || val == 'Guernsey Hotel'){
          //                    
     }else{
          //
     }
}

希望这有帮助

There is not a lot of information to go on here, would have been nice to see you html for the selects.

However one thing i noticed is your if and else if are identical, were your intentions to do something like:

function test(val){
     alert(val);
     if(val == 'Jersey Airport' || val == 'Jersey Harbour' || val == 'Jersey Hotel'){
          //                  
     }else if(val == 'Guernsey Airport' || val == 'Guernsey Harbour' || val == 'Guernsey Hotel'){
          //                    
     }else{
          //
     }
}

Hope this helps

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文