PDA

View Full Version : Remote windows


aaron_stinson
02-18-2003, 08:46 PM
Is there a way to wite values in a text box from a remote windw.
Here is what I am trying to do:

Can I copy a textbox's value in form1 to a text box on form 2 which is located on a separate page. For instance, let's say I want to copy info from:

A form called "birorder" located at testorder.htm
textbox= "zip2'

To

A form called "upsform" located at ups1.htm
textbox= "postal"

I have been trying to use the variable that I opened the window with to assign the value and I have tried using window.opener to access the value. But I can't get it to work.

CONFIQ
02-18-2003, 08:51 PM
i don't think it's possible,perhaps with MSIE and 5KB of javascript.
But why don't you write in frame windows?

glenngv
02-19-2003, 02:19 AM
what's the relationship of the two windows? Does the first window (testorder.htm) opens the 2nd window (ups1.htm)? If that is the case, then:

//in ups1.htm:
if (window.opener && !window.opener.closed){//check if opener is open
document.upsform.postal.value=window.opener.document.birorder.zip2.value;
}

aaron_stinson
02-19-2003, 02:47 AM
I tried that and cant get it to work. I have tried a lot of different ways, or as many as I could think of and could not ever get it to work. I guess I will just have to use frames.

glenngv
02-20-2003, 02:46 AM
I think window.parent is used in frames. A window's parent (in a frame) is its frameset window where that frame is located. But, I think, this is not applicable to a window spawning a new window.
window.opener should be used instead.

testorder.htm:
<html>
<body>
<form name="birorder">
<input type="text" name="zip2">
<input type="button" value="Open" onclick="window.open('ups1.htm')">
</form>
</body>
</html>

ups1.htm:
<html>
<head>
<script language="javascript">
function getValue(){
if (window.opener && !window.opener.closed){//check if opener is open
document.upsform.postal.value=window.opener.document.birorder.zip2.value;
}
}
</script>
</head>
<body>
<form name="upsform">
<input type="text" name="postal">
<input type="button" value="Get value from Parent" onclick="getValue()">
</form>
</body>
</html>

if you want to automatically put the value from parent instead of clicking a button, then you just call getValue() onload of the page:
<body onload="getValue()">

A1ien51
02-20-2003, 03:54 AM
LOL....I was programming in Frames before I posted this, and was not thinking....lol