【发布时间】:2016-03-24 22:27:32
【问题描述】:
我想通过响应下拉列表更改的 JavaScript 函数调用 HTML 按钮。但由于某种原因,它没有找到正确的 id。
@using (Ajax.BeginForm("GetReport", "Choices",
new AjaxOptions() {
InsertionMode = InsertionMode.Replace,
HttpMethod = "GET",
UpdateTargetId = "reportResults",
}
)) {
@Html.DropDownList("q",(IEnumerable<SelectListItem>)ViewData["YearTermList"], htmlAttributes: new { @class = "form-control" })
<br />
@Html.DropDownList("ChartList", null, htmlAttributes: new { @class = "form-control" })
<br />
<input type="submit" style="display:none" id="ShowList" value="Search"/>
}
<script type="text/javascript">
$(document).ready(function () {
$("#YearTermList").change(function () {
$("#ShowList").click();
});
});
</script>
JavaScript 函数不提交下拉列表更改上的按钮。
【问题讨论】:
-
您没有任何带有
id="YearTermList"的元素(只有id="q"和id="ChartList")。
标签: javascript jquery html asp.net asp.net-mvc