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

2
  • 1
    possible duplicate of jQuery/Javascript - reload current page with an appended querystring? Commented Jul 19, 2010 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. Commented Jul 19, 2010 at 13:27

2 Answers 2

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.

Sign up to request clarification or add additional context in comments.

Comments

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.