Click to See Complete Forum and Search --> : Passing a var from window to window...again...
I know there are already quite a few posts on passing values between windows but all of them seem to be taking the value of a text field or some form element and populating another text field on another page with the value. All I want to do is pass a variable from one page to another.
Thanks, Lizo.
requestcode
07-21-2003, 07:43 AM
You can attach the value to the URL and then extract it in the next page like this:
x="some value"
a="another value"
linkid="next_page.html?"+x+"&"+a
location.href=linkid
Then on the next page you would extract it like this:
var passdata=unescape(location.search.substring(1,location.search.length))
var tdata=passdata.split("&")
"tdata[0]" would now contain the value "some value" and tdata[1] would contain the value "another value".
Thanks 'requestcode' that does exactly what I wanted. :D
Ok,
Ive got all that working. I want to do something slightly different this time...
The parent window opens a child window. The child window gets the value from a cookie, and I want the child window to send the value back to the parent. The parent is still open thats why its slightly different. And when the value gets passed to the parent I want it to just go in to a variable not to populate a text box or anything.
So, one value from one page to another.
Thanks, Lizo.
Try something along these lines:
window.opener.varname = "somevalue";
Ok thanks for that.
Ive now realised that isnt really what I want to do anymore, it just wont work with what I need to do.
Rather than passing a variable, is there any way of calling a function located in the parent window from the child window and using the var as the argument.
This seems a lot more complex :confused: and im sorry for wasting peoples time.
Lizo.
If this cant be done, is there anyway at all of simulating it??
I really need this to work :rolleyes: .
Ok I kind answered my own question with curiosity...
window.opener.functionName();
Thanks to everyone anyway.