My view has a dropdown list, that depending on the option selected, will redirect you to another page/controller. I'm using javaScript to get the selected value of my dropdown list but have trouble trying to manipulate Html.BeginForm. Here is part of my view
@{ var newView=0;
var page = "";
var cont = "";
}
<script type="text/javascript" language="javascript">
function run() {
newView = document.getElementById('views').value;
}
function ButtonClicked() {
alert("View selected: " + newView );
// update variables page and cont here?
}
</script>
<select name="views" id="views" onchange="run()">
<option value="0"> </option>
<option value="1">Option 1</option>
<option value="2">Option 2</option>
</select>
@using (Html.BeginForm(page, cont, FormMethod.Post))
{
<button onclick="javascript:ButtonClicked()" type="submit" class="btn"> Go </button>
}
How can I update the action of submit button in Razor view?
I tried to replace "Index" and "Home" for variables and update them in my functions, but its not working....any ideas?
-----Note: I updated my question to be more specific with my problem