I\'ve got a dropdown menu on my form, which when something is selected I need to reload the current page, but with an appended querystring.
How would I go about doing th
If you want a really simple way to preserve the query string and possibly append to it, use window.location.search
; here's a snippet:
var search = window.location.search + (window.location.search ? "&" : "?");
search += "param1=foo¶m2=bar";
window.location.href = window.location.protocol + "//" + window.location.host + window.location.pathname + search;
You can, of course, use a more sophisticated way of building the rest of your query string, as found in the other examples, but the key is to leverage Location.search
.