Check out my code below:
<div class="center">
<p> Choose an item: </p>
<div class="dropdown">
@using (Html.BeginForm("Start", "Home", FormMethod.Post, new { name = "form", id = "form" }))
{
@Html.DropDownListFor(x => x.SelectedId, @Model.ViewJaren,
new
{
onchange = "this.parentNode.form.submit()"
}
)
}
</div>
</div>
I've been trying to make it work but I'm stuck. I managed to get the onchange
event working with document.getElementById("form")
, however, no value is being passed and all I see is a blank page.