Skip to content

Instantly share code, notes, and snippets.

@spolischook
Created November 25, 2015 03:20
Show Gist options
  • Save spolischook/9480f5fd8421bc67e645 to your computer and use it in GitHub Desktop.
Save spolischook/9480f5fd8421bc67e645 to your computer and use it in GitHub Desktop.
function pager(val) {
var pager = document.getElementById("log_search_type_limit"),
perpage = pager.options[pager.selectedIndex].value,
url = replaceQueryParam('limit', perpage, window.location.search);
window.location = window.location.pathname + url;
}
function replaceQueryParam(param, newval, search) {
var regex = new RegExp("([?;&])" + param + "[^&;]*[;&]?");
var query = search.replace(regex, "$1").replace(/&$/, '');
return (query.length > 2 ? query + "&" : "?") + (newval ? param + "=" + newval : '');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment