Skip to content

Instantly share code, notes, and snippets.

@boz14676
Created April 14, 2019 15:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save boz14676/cc12afebc8d1ea4682cc22bdb3725a7e to your computer and use it in GitHub Desktop.
Save boz14676/cc12afebc8d1ea4682cc22bdb3725a7e to your computer and use it in GitHub Desktop.
function updateURLParameter(url, param, paramVal) {
var newAdditionalURL = "";
var tempArray = url.split("?");
var baseURL = tempArray[0];
var additionalURL = tempArray[1];
var temp = "";
if (additionalURL) {
tempArray = additionalURL.split("&");
for (var i=0; i<tempArray.length; i++){
if(tempArray[i].split('=')[0] != param){
newAdditionalURL += temp + tempArray[i];
temp = "&";
}
}
}
var rows_txt = temp + "" + param + "=" + paramVal;
return baseURL + "?" + newAdditionalURL + rows_txt;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment