简体   繁体   English

如何在mvc5中填充下拉列表,以使每个列表都取决于上一个下拉列表?

[英]How can i populate drop down lists in mvc5 such that each list is dependent on the previous drop down list?

How can i populate drop down lists in mvc5 such that each list is dependent on the previous drop down list? 如何在mvc5中填充下拉列表,以使每个列表都取决于上一个下拉列表? Example: Database stores information on cars first field drop down list should display all car manufacturers, depending on my selection the second field drop down list should only display data of car models for the brand i have selected. 示例:数据库中有关汽车的信息存储第一个字段下拉列表应显示所有汽车制造商,根据我的选择,第二个字段下拉列表应仅显示我选择的品牌的汽车型号数据。

You should use js for dropdown 'change' event. 您应该使用js进行下拉“更改”事件。 Then at least two options are possible. 那么至少有两个选择是可能的。 Ajax request for next drop down values (different libs like select2 could handle that scenario out of the box) or form posting to the action, which will render it back with the next dropdown values provided. Ajax请求下一个下拉值(选择库之类的不同的lib可以立即解决该情况)或将表单发​​布到操作中,这将使用提供的下一个下拉值将其返回。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM