Click to See Complete Forum and Search --> : working between two pages


Bryan Tuffin
01-13-2003, 09:32 PM
How can you use javascript to copy text from a form in one window to a form in a completely separate window. And what do I have to do if the forms are in frames pages.

pyro
01-13-2003, 09:52 PM
What exactly are you looking to do? Maybe if you explain what you need, we can tell you how to go about it. It totally depends what you need to do for how you need to go about it. (ie. is it frames, a new window that you open, etc)

khalidali63
01-13-2003, 09:53 PM
you can pass data froma frame to another frame and parent window to a child window,other then that you can not use JavaScript or any other way to pass data between windows.

data to child window

childEindowName.document.objectName.value
from child to parent window
top.opener.document.objectName.value

and same goes with frames
you can access any frame in a frameset
parent.frames[x].document.objectName.value
........

Khalid

Bryan Tuffin
01-13-2003, 11:18 PM
I am trying to display text in a second window. In the code below I would like to display the text stored in hold in a form in the second window I just opened. and how do I send text back to returned_text in the first window.







<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>NewPage1</title>

<Script language="javascript">

var hold
var returned_text

function try_test() {

hold = document.forms.formtest1.test1.value;
window.open("display.htm","display_window","width=600,height=500,resizable=yes,scrollbars=yes,toolbar=no,location=no,directories=no,status=no,me nubar=no,copyhistroy=yes");
//more code needed here.
}
</script>

</head>

<body>

<form name="formtest1">
<p><input type="text" name="test1" size="20"><input type="button" value="test" onclick="Javascript:try_test()" name="testbutton1"></p>
</form>

</body>

</html>

pyro
01-13-2003, 11:23 PM
You shouldn't need the hold...Something like this in your popup should work. window.opener.document.forms.formtest1.test1.value.

Bryan Tuffin
01-13-2003, 11:46 PM
I need to be able to work between the two windows at a later time after the second window has been opened and need to know the procedure to transfer text back and forth between the two windows.

pyro
01-13-2003, 11:48 PM
Did you try what I suggested? It should allow you to get text from the window that opened your popup.

Bryan Tuffin
01-14-2003, 02:59 AM
ok! I gave it a try I used window.opener in the second window to get text from the first window and it worked. but I still can not get it to work when I use window.opener in the first window to get text from the second window. how do I use javascript written in either window to access the other.

swon
01-14-2003, 12:21 PM
You can do it this way:

Opener.htm:

<Script language="javascript">
function try_test() {
hold = document.formtest1.test1.value;
w = window.open("display.htm","display_window"," width=600,height=500,resizable=yes,scrollbars=yes,toolbar=no,location=no,directories=no,status=no,me nubar=no,copyhistroy=yes");
setVal(hold);
}

function setVal(hold){
w.top.document.testing.test.value=hold;
}
</script>

And display.htm:

<script language="JavaScript">
<!--
function SendBack(){
window.opener.document.formtest1.test1.value= document.testing.test.value;
}
//-->
</script>
<body>
<form name=testing action="" method="" target="">
<input type=text name=test><input type=button value="Fill out and send back" onClick="SendBack()">
</form>
</body>