在客户端,我需要使用选择器的Id作为参数调用javascript函数“changeSchool”,因为很快用户选择新选项(在这种情况下是学校)。如何将选择器的Id传递给这样的javascript函数?
视图中的表包含以下下拉列表:
@{
for (var i = 0; i < Model.StudentApplications.Count(); i++)
{
<tr>
...
<td>@Html.DropDownListFor(m => m.StudentApplications[i].SchoolId, Model.StudentApplications[i].SchoolList, new { onchange = "changeSchool(?);" })</td>
...
</tr>
}
}
编辑:
从源代码我可以看到生成了id:id =“StudentApplications_0__SchoolId”, id =“StudentApplications_1__SchoolId”,... 等。
答案 0 :(得分:0)
也许?
onchange = "changeSchool(" + Model.StudentApplications[i].SchoolId + ");"