How to collect variables from a URL, insert them into an array and dynamically change
How to collect variables from a URL, insert them into an array and dynamically change a href URLs?
I'm not a developer so please be easy on me here! I am familiar with HTML and not bad at taking snippets of code from various sources and cobbling them together. I've been looking around and just can't seem to find exactly what I need. Very close and yet so far.. Please help!
What I want to do is:
1. collect variables from the URL like this (www.myurl.com/index.html?var1=1&var2=2&var3=3 etc. etc..)
2. Take those variables and insert them into an array while stripping out the un-needed parts. I found this code which gets it but prints it on the screen, which I don't need..
var parameters = location.search.substring(1).split("&");
var temp = parameters.split("=");
l = unescape(temp);
temp = parameters.split("=");
c = unescape(temp);
document.getElementById("log").innerHTML = l;
document.getElementById("pass").innerHTML = c;
<p>http://www.myurl.com/</b><span id="log" ></span></p>
3. Dynamically alter a href tags on the fly based on the parameters gathered from the URL.
I found this code which works great to alter the URLs but (a) the variable is gathered from an input form and I need to be able to take them from the URL. (b) I also need several of them (could be like 20) so an array is needed.
<input type="text" id="mySearchBox" /> <a href="myurl.com/index.html?"; onclick="this.href+=+document.getElementById('mySearchBox').value">Enter Parameter</a>
I'm sure this is like elementary school stuff to you out there but I just can't seem to figure it out so your advice is much appreciated!