【发布时间】:2014-03-20 13:01:23
【问题描述】:
我是 javascript 的初学者。
我尝试在 Asp.net Mvc 中使用 Html.Dropdownlist。
我有 1 个下拉列表和其他 4 个下拉列表。
如果 1.dropdownlist 更改值,我想通过在 javascript 中使用 foreach 为 4 个下拉列表应用 1.dropdownlist 值。
HTML:
@Html.DropDownList("MainDropDownList", listItems, "Select", new { @id = "MainDropDownListID" })
// İf this dropdownlist value changes , i want to apply value to other dropdownlists.
<table>
<tr>
<td>@Html.DropDownList("MyDropDownList1", listItems)</td>
<td>@Html.DropDownList("MyDropDownList2", listItems)</td>
<td>@Html.DropDownList("MyDropDownList3", listItems)</td>
<td>@Html.DropDownList("MyDropDownList4", listItems)</td>
</tr>
</table>
Javascript:
$(function () {
$('select#MainDropDownListID').change(function () {
var SelectedValue = $(this).val();
//How can i apply selectedvalue to 4 dropdownlists value using foreach ?
});
});
【问题讨论】:
标签: c# jquery asp.net-mvc html-select