1

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/?querystring=something

Probocop
  • 10,346
  • 28
  • 85
  • 115
  • 1
    possible duplicate of [jQuery/Javascript - reload current page with an appended querystring?](http://stackoverflow.com/questions/3281020/jquery-javascript-reload-current-page-with-an-appended-querystring) – jAndy Jul 19 '10 at 13:20
  • Do you want "?querystring=something" to be added always, or when a specific entry is selected to the drop down. Also can you show more code, especially the form? There are different ways to do this but it depends on what you are trying to do. NB: Consider that not everyone can use/wants to use JavaScript. – RoToRa Jul 19 '10 at 13:27

2 Answers2

1

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.

Har
  • 4,864
  • 2
  • 19
  • 22
1

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.

augustomen
  • 8,977
  • 3
  • 43
  • 63