I am beginner on javascript.
I try to use Html.Dropdownlist in Asp.net Mvc.
I have 1 dropdownlist and other 4 dropdownlists.
If 1.dropdownlist change value , i want to apply 1.dropdownlist value for 4 dropdownlists by using foreach in javascript.
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 ?
});
});