對不起,如果我的問題標題不是很清楚,因爲我不知道如何總結。基於下拉列表選擇更新視圖
因此,我在這裏的場景是提供一個供用戶選擇的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
,然後用基於的數據填充。我應該怎麼做?
那麼你面臨的問題是什麼? –