views:

103

answers:

1

Hi, 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 this?

+1  A: 
var params = [
    "foo=bar",
    "base=ball"
];

window.location.href = "http://" + window.location.host + window.location.pathname + '?' + params.join('&');

That code within your change event handler will do the trick.

For instance:

$('#my_dropdown_id').bind('change', function(){
    var params = [
        "foo=bar",
        "base=" + $(this).val()
    ];

    window.location.href = "http://" + window.location.host + window.location.pathname + '?' + params.join('&');
});
jAndy