Click to See Complete Forum and Search --> : Transfer form information from one window to another


rav
05-09-2003, 01:08 PM
Is it possible to have one window (A) spawn another window (B), gather user input from (B) and transfer it to (A)?

Charles
05-09-2003, 01:12 PM
Yes, it's posible and quite simple. But how is this going to work for all the people who do not use JavaScript?

rav
05-09-2003, 01:14 PM
That is not my concern. This is for a private webpage.

Jona
05-09-2003, 01:19 PM
Page A:

<html><head>
<script>
function popwin(){
var win = window.open("pageb.html");
</script>
</head><body>
<a href="javascript:popwin()">Pop</a><br>
<div id="info">Information will be stored here</div>
</body></html>

Page B:

<html><head>
<script>
function sendBack(){
opener.document.getElementById("info").innerHTML=document.myForm.myTextarea.value;
}
</script></head><body>
<form name="myForm">
<textarea name="myTextarea" rows="5" cols="5">
Okay.. this goes to the DIV in the opener
</textarea>
<input type=button onClick="sendBack()" value="Send to opener">
</form></body></html>

Charles
05-09-2003, 01:21 PM
The Window.open () method returns an object that you can use to get at the child window:

var child = window.open();
child.document.forms[o];

And you can get at the opener from the child with the object opener:

top.opener.someVariable = '45';
top.opener.someFunction();

rav
05-09-2003, 01:24 PM
Brilliant!