Created
April 14, 2019 15:26
-
-
Save boz14676/cc12afebc8d1ea4682cc22bdb3725a7e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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