Forums
This topic is locked
Sending Variables Between Windows
Posted 18 Jul 2006 18:41:28
1
has voted
18 Jul 2006 18:41:28 Matt Bailey posted:
Does anyone know how to send a variable from a 'Popped Up' window back to a 'Parent' window using javascript? Basically I want to build a simple pop-up image browser so a user can pick an image and have the image's filename sent back to the main parent window for storage in a database.___________________________________
"Some people say if you play a windows cd backwards it plays satanic messages. That's nothing, because if you play it forwards it installs windows!"
Replies
Replied 19 Jul 2006 16:42:57
19 Jul 2006 16:42:57 Matt Bailey replied:
Ok, after looking for a few days I finally found what I was looking for. Here's the code in case anyone else needs to know:
<b>Contents of first page (doc1.htm):</b>
<pre id=code><font face=courier size=2 id=code><script language="JavaScript"><!--
function newWindow(file,window) {
msgWindow=open(file,window,'resizable=no,width=200,height=400');
if (msgWindow.opener == null) msgWindow.opener = self;
}
//--></script></font id=code></pre id=code>
<pre id=code><font face=courier size=2 id=code><form name="outputForm1">
<input type="button" value="Open doc2.htm into window2" onClick="newWindow('doc2.htm','window2')">
<br><input name="outputField1" type="text" value="">
<br><input name="outputField2" type="text" value="">
</form></font id=code></pre id=code>
<b>Contents of second page/pop-up window (doc2.htm):</b>
<pre id=code><font face=courier size=2 id=code><script language="JavaScript"><!--
function setForm() {
opener.document.outputForm1.outputField1.value = document.inputForm1.inputField1.value;
opener.document.outputForm1.outputField2.value = document.inputForm1.inputField2.value;
self.close();
return false;
}
//--></script></font id=code></pre id=code>
<pre id=code><font face=courier size=2 id=code><form name="inputForm1" onSubmit="return setForm();">
<br><input name="inputField1" type="text" value="">
<br><input name="inputField2" type="text" value="">
<br><input type="submit" value="Update opener">
</form></font id=code></pre id=code>
Bingo!
___________________________________
"Some people say if you play a windows cd backwards it plays satanic messages. That's nothing, because if you play it forwards it installs windows!"
<b>Contents of first page (doc1.htm):</b>
<pre id=code><font face=courier size=2 id=code><script language="JavaScript"><!--
function newWindow(file,window) {
msgWindow=open(file,window,'resizable=no,width=200,height=400');
if (msgWindow.opener == null) msgWindow.opener = self;
}
//--></script></font id=code></pre id=code>
<pre id=code><font face=courier size=2 id=code><form name="outputForm1">
<input type="button" value="Open doc2.htm into window2" onClick="newWindow('doc2.htm','window2')">
<br><input name="outputField1" type="text" value="">
<br><input name="outputField2" type="text" value="">
</form></font id=code></pre id=code>
<b>Contents of second page/pop-up window (doc2.htm):</b>
<pre id=code><font face=courier size=2 id=code><script language="JavaScript"><!--
function setForm() {
opener.document.outputForm1.outputField1.value = document.inputForm1.inputField1.value;
opener.document.outputForm1.outputField2.value = document.inputForm1.inputField2.value;
self.close();
return false;
}
//--></script></font id=code></pre id=code>
<pre id=code><font face=courier size=2 id=code><form name="inputForm1" onSubmit="return setForm();">
<br><input name="inputField1" type="text" value="">
<br><input name="inputField2" type="text" value="">
<br><input type="submit" value="Update opener">
</form></font id=code></pre id=code>
Bingo!
___________________________________
"Some people say if you play a windows cd backwards it plays satanic messages. That's nothing, because if you play it forwards it installs windows!"