<h3>URL GET and value parameters</h3>
<p><b>Try with:</b> https://stats.nba.com/stats/teamgamelog?DateFrom=&DateTo=&LeagueID=00&Season=2020-21&SeasonType=Playoffs&TeamID=1610612749</p>
<form style="padding-top: 1rem;">
<label for="url">URL: </label>
<input id="url" type="text" onkeyup="updateParams(this.value);" />
</form>
<div id='output-div'>
</div>
function URLQueryAsArray(str) {
let params = new URLSearchParams(str);
let params_array = [];
for (let value of params.keys()) {
params_array.push([value, params.get(value)]);
}
return params_array;
}
function updateParams(val) {
document.getElementById("output-div").innerHTML = "";
let split_url = val.split("?");
let query_string = split_url[1];
let p_array = URLQueryAsArray(query_string);
let output_div = document.getElementById("output-div");
for (let index = 0; index < p_array.length; ++index) {
let p_string = p_array[index][0] + " => " + p_array[index][1];
let newNode = document.createElement("p");
newNode.innerHTML = p_string;
output_div.appendChild(newNode);
}
}
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.