Page 1 of 1

Passing information between windows

Posted: Tue May 09, 2006 12:46 pm
by Luke
Is it possible to pass a variable from a popup window back to the window that popped it up? For instance: I want to be able to click on something in the popup and have it change the dropdown (select element) in the original window. Is this possible?

Posted: Tue May 09, 2006 1:08 pm
by angus
are you using php?

could you put it into a session variable and collect it on the other end.

or if your using JS to do all this set a cookie ...

Posted: Tue May 09, 2006 1:15 pm
by Luke
I'm pretty sure is has to be client-side. I don't have direct access to any files because I am working with MIVA merchant. I thought there was a wy to do something sorta like this, but I can't find info about it:
(This is the popup window)

Code: Select all

mainWindowName.formname.formelement.value = "FOO";

Posted: Tue May 09, 2006 2:02 pm
by Burrito

Code: Select all

opener.document...

Posted: Tue May 09, 2006 2:06 pm
by RobertGonzalez
This comes straight out of phpBB's user administration. I am sure there is some importance on form names and window names.

This page pops the window open when you click the 'Find a username' button...

Code: Select all

<form method="post" name="post" action="formaction.php">
Select a User<br />
<input type="text" class="post" name="username" maxlength="50" size="20" /> 
<input type="hidden" name="mode" value="edit" />
<input type="submit" name="submituser" value="Look up user" class="mainoption" /> 
<input type="submit" name="usersubmit" value="Find a username" class="liteoption" onClick="window.open('./../search.php', '_search', 'HEIGHT=250,resizable=yes,WIDTH=400');return false;" />
This code allows you to select a user from a select list and it will send that information back to the calling page...

Code: Select all

<script language="javascript" type="text/javascript">
<!--
function refresh_username(selected_username)
{
	opener.document.forms['post'].username.value = selected_username;
	opener.focus();
	window.close();
}
//-->
</script>

<form method="post" name="search" action="search.php?mode=searchuser">
<select name="username_list">
<option value="me">me</option>
<option value="you">you</option>
</select>&nbsp; 
<input type="submit" class="liteoption" onClick="refresh_username(this.form.username_list.options[this.form.username_list.selectedIndex].value);return false;" name="use" value="Select" />
<br /><br />
<a href="javascript:window.close();" class="genmed">Close Window</a>
</form>

Posted: Wed May 10, 2006 12:05 pm
by Luke
Awesome... works PERFECTLY!!

Posted: Wed May 10, 2006 12:15 pm
by RobertGonzalez
Sweet! That's at least two times in my life that I helped someone! :wink: