Page 1 of 1
two windows, sending data between....
Posted: Wed Aug 14, 2002 5:06 am
by 9902468
Sorry if I missed something, but after a little searching and googleing I was unable to find the answer:
I have one page that has few add [something] buttons. When user presses the button it opens new window, where user can select something from a list and when he/she presses ok the newer window should close, and changes should be updated to the main window.
The story so far: I happily made script to open new window, and controls to that new window.
Problem:
How can I tell the main window to update it self after user has pressed ok (the new window ok button, values are in session, so only refresh is required..) Also how can I now close the new window?
Thanks,
-9902468
Posted: Wed Aug 14, 2002 5:14 am
by Beefy
You could reload the main window with http-meta-refresh periodically, but that won't really solve your problem.
Another solution: The new window sends the information to the old window and closes itself...
Code: Select all
/* mainwindow.php */
if($go='ok') echo 'case 1';
else echo 'case 2 <input type="submit">"; /* This button opens the newwindow */
/* newwindow.php
<form action="mainwindow.php">
<input type="submit" name="go" value="ok"> <!-- This button sends all information to the main window (look at the form action) -->
</form>
Posted: Wed Aug 14, 2002 5:21 am
by 9902468
I thought that
just loads somepage.php file to THIS window? (where the form tag is)
Posted: Wed Aug 14, 2002 5:50 am
by 9902468
ok. I can close the window with js (onsubmit) , so is it even possible to tell that other window to refresh? Anyone?
Posted: Wed Aug 14, 2002 6:08 am
by Beefy
9902468 wrote:I thought that
just loads somepage.php file to THIS window? (where the form tag is)
You're right.
I thought that would'nt matter.
Well, I'm sorry, but I don't know any JS.
Posted: Wed Aug 14, 2002 8:43 am
by fatalcure
yes there is a way, look up javascript and passing variables from one browser to the next, im pretty sure it can be done, its even done (something similar) on this forum, when you click on VIEW MORE EMOTICONS, where you select an emoticon from a remote window, and it adds it to the main window's Message Body. So you could just call a function in the main window from the Remote window and the function would refresh the page.
Hope this helps.
Posted: Wed Aug 14, 2002 9:20 am
by Johnm
Try this:
In the parent page add:
Code: Select all
<input type="hidden" name="var_name">
In the child page add:
Code: Select all
<script>
function SubmitToParentPage(form)
{
window.opener.document.formsї0].var_name.value=
form.child_page_var.value;
form.submit();
window.close();
}
</script>
add this to the bottom of the child page:
Code: Select all
<input type="button" value="Submit"
onClick="SubmitToParentPage(this.form)">
Direwolf
boooooya...
Posted: Wed Aug 14, 2002 10:07 am
by fatalcure
try this:
PARENT WINDOW CODE
Code: Select all
<script language="JavaScript">
<!--
function new_window() {
self.name = "Parent_Window";
var new_window = "scrollbars,resizable,width=250,height=150,left=700,top=25";
OpenWindow = window.open("remote.htm", "remote", new_window);
}
function refresh_window() {
window.location.reload( true );
}
-->
</script>
<a href="javascript:onClick=new_window();">Open Remote Window</a>
REMOTE WINDOW CODE
Code: Select all
<a href="javascript:refresh_window();" target="Parent_Window" onClick="window.close()">Refresh main window and Close this remote.</a>

Posted: Thu Aug 15, 2002 12:16 am
by 9902468
Ok thanks! I'll try out what you succested.