如何使用mvc4中的另一个下拉列表填充html.dropdown列表 [英] How do I Fill a html.dropdown list with another dropdown list in mvc4

查看:83
本文介绍了如何使用mvc4中的另一个下拉列表填充html.dropdown列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我认为它有两个下拉列表。第一次下拉已经填满。我想用第一个下拉项目和数据库guery填充另一个下拉列表。

解决方案

使用此脚本

这会触发更改事件你选择第一个下拉索引

#State id是第一个下拉列表的id









@ Html.DropDownList(State,ViewBag.StateName as SelectList,Select the State,new {id =State})







 <   script     type   =  text / jscript >  

(function(){


('#State')。change(function(){


I have a view that it has two drop down list. the first drop down has filled. I want to fill another drop down with first drop down Item and database guery.

解决方案

Use this script
This fires a change event when u select the first drop down index
#State id is the id of the first drop down list




@Html.DropDownList("State", ViewBag.StateName as SelectList, "Select the State", new { id = "State"})



<script type="text/jscript">


(function () {


('#State').change(function () {


这篇关于如何使用mvc4中的另一个下拉列表填充html.dropdown列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆