对不起,如果我的问题标题不是很清楚,因为我不知道如何总结。基于下拉列表选择更新视图
因此,我在这里的场景是提供一个供用户选择的checkbox
选择列表。此选择列表将根据dropdownlist
选择而有所不同。到目前为止,这是我实现,但我真的不知道如何使用jQuery操纵从视图选择列表:
查看:
<div class="form-group">
@Html.LabelFor(model => model.moduleID, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.DropDownListFor(model => model.moduleID, new SelectList(Model.ModuleList, "value", "text"),
"- Please select a Module -", new { @onchange = "PopulateObj()", @class = "form-control" })
</div>
</div>
<table class="table">
@for (int i = 0; i < Model.ObjectiveList.Count(); i++)
{
<tr>
<td>
@Html.CheckBoxFor(model => model.ObjectiveList[i].isAssigned)
@Html.DisplayFor(model => model.ObjectiveList[i].text)
@Html.HiddenFor(model => model.ObjectiveList[i].text)
</td>
</tr>
}
</table>
脚本:
<script>
function PopulateObj() {
var moduleID = $('#moduleID').val();
//implementation to change Model.ObjectiveList
}
</script>
基本上,我想从dropdownlist
选项中获得model.moduleID
,然后用基于的数据填充。我应该怎么做?
那么你面临的问题是什么? –