我有2个下拉列表。区域和分区。当我选择一个区域时,我想填充子区域下拉列表。我没有击倒所有工作但我无法弄清楚如何使用敲除数据绑定而不是js来处理更改事件。
脚本:???
html:
<div class="col-md-10">
@Html.LabelFor(model => model.AreaID, new { @class = "control-label col-md-2" })
@Html.DropDownList("AreaID", AreaList, new { @class = "form-control" })
@Html.ValidationMessageFor(model => model.AreaID)
</div>
<div class="col-md-10">
@Html.LabelFor(model => model.AreaNodeID, new { @class = "control-label col-md-2" })
@Html.DropDownList("AreaNodeID", new List<SelectListItem>(), new { @class = "form-control" } )
@Html.ValidationMessageFor(model => model.AreaNodeID)
</div>
答案 0 :(得分:0)
@Html.DropDownList("AreaID", AreaList, new { @class = "form-control" },
new { onchange = "FetchStates();" })
function FetchStates() {
var countryCode = $("#AreaID").val();
$.getJSON("/Home/GetStates/" + countryCode, null, function (data) {
objVM.states(data);
});