Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jquery dropdownlist, onchange reload page using Get request with ID of dropdown value

When someone selects an item in a dropdown, I want to reload the current page with the value of the ID in the selected item in the querystring like:

http://www.example.com/mypage?id=234

How can I do this?

like image 375
Blankman Avatar asked Sep 14 '10 15:09

Blankman


1 Answers

<select id="items" onselect="javascript:reloadPage(this)">
  <option name="item1">Item 1</option>
</select>

script:

function reloadPage(id) {
   document.location.href = location.href + '?id=' + id.value;
}
like image 193
Stephan Muller Avatar answered Oct 19 '22 18:10

Stephan Muller