How to collect variables from a URL, insert them into an array and dynamically change a href URLs?
Hi
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..
[CODE]
myurl.com/index.html?log=1&pass=2
function addComment()
{
var parameters = location.search.substring(1).split("&");
var temp = parameters[0].split("=");
l = unescape(temp[1]);
temp = parameters[1].split("=");
c = unescape(temp[1]);
document.getElementById("log").innerHTML = l;
document.getElementById("pass").innerHTML = c;
}
addComment();
<p>http://www.myurl.com/</b><span id="log" ></span></p>
<p>http://www.myurl.com/</b><span id="pass"></span></p>
</script>
[CODE]
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.
[CODE]
<input type="text" id="mySearchBox" /> <a href="myurl.com/index.html?"; onclick="this.href+=+document.getElementById('mySearchBox').value">Enter Parameter</a>
[CODE]
Regarding the technology... I'm not stuck on any particular language or method but javascript and the jquery seems to be the easiest for me. I haven't done much with PHP and other languages. The easiest method for dummies you can provide the better.
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!