I am trying to send a variable from one page to another through the URL.
I am using this line in the first page :
document.location.href="./pageOne.html?MyVariable=value";
and it works, but on the new page, I do not know how to take the value from the URL....please help me.
Comments
[code]
myVars = document.location.search
[/code]
HTH
: I am trying to send a variable from one page to another through the URL.
:
: I am using this line in the first page :
: document.location.href="./pageOne.html?MyVariable=value";
:
: and it works, but on the new page, I do not know how to take the value from the URL....please help me.
:
:
: [code]
: myVars = document.location.search
: [/code]
:
: HTH
:
: : I am trying to send a variable from one page to another through the URL.
: :
: : I am using this line in the first page :
: : document.location.href="./pageOne.html?MyVariable=value";
: :
: : and it works, but on the new page, I do not know how to take the value from the URL....please help me.
: :
: :
:
:
Hi there,
Here's the code I use for this method...
[code]
function getValue(key) {
var searchString = unescape(document.location.search.substring(1, document.location.search.length));
var pairs = [];
var kv = [];
pairs = searchString.split("&");
for (var i = 0; i != pairs.length; i++) {
kv = pairs[i].split("=");
if (kv[0] == key) {
return kv[1];
}
}
}
[/code]
Now it's just a matter of...
[code]
var key1 = getValue("key1");
var key2 = getValue("key2");
etc...
[/code]
HTH
Bradley q:)