I have a dropdown menu, which I want to use $('form#form').submit();
on from a .change()
event, but how would I append a query string to the submitted page?
So the resulting page would be example.com/submitted-form/?qu开发者_开发百科erystring=something
If I understand it right, you want to set up your form like:
<form id="form" method="get" action="">
<select name="querystring">
...dropdown menu...
</select>
</form>
By submitting this form, you will be directed to the same page, appending the query string.
Assuming
@using (Html.BeginForm("Index", "VO", FormMethod.Post, new { id = "MyForm" }))
{
}
or
<form action="/VO" id="MyForm" method="post"></form>
You've got to hyjack your action property
$("#MyForm").attr("action", "/VO?Page=" + $(this).text());
$("#MyForm").submit();
You will get your form elements plus that so very useful query string parameter.
精彩评论