Page 2 of 3

Posted: Thu Aug 25, 2005 6:31 am
by mur
Thank you!! I totally get it now. So much to learn, so little time. I'll post my final code here once I get it working. Hopefully it will be able to work for any form created in html.

Thanks alot,
Mur

Posted: Thu Aug 25, 2005 7:39 pm
by mur
I am nearly done with my code, the only thing that I need to know how to do is get to get the name of the form, from the form tag.

Code: Select all

<form action="a.php" method = "POST" name="form1" target="_blank" id="form1">
i am hoping to be able to get the name "form1" as a variable in my php script.

How can I do this?

Posted: Thu Aug 25, 2005 7:42 pm
by Stewsburntmonkey
I think the best thing to do would be to create a hidden input field and use it to store the name of the form.

Code: Select all

<input type="hidden" name="formName" value="form1">

Posted: Thu Aug 25, 2005 7:45 pm
by mur
That is a good idea, I was just wondering if there was a way to get the form name, but i guess this is just as good, I tried using a label within the form, but those don't get carried over into the $_POST. Thanks for the quick response.

Posted: Fri Aug 26, 2005 11:00 pm
by mur
While working on this code I came across another problem. I have the php window that I resized in javascript because I could not find a way in PHP. And after the form is submitted, and checked to be filled I need to close the php window and set the parent window that has the form to another webpage.

I cannot use teh onsubmit in html because I have to check the form to be sure that all of the required fields are filled, and this could take several submits. I am just looking for a PHP command to close the current window, and change the parent, and also, if there is a way to resize in PHP, that would be helpful.

Thanks
Mur

Posted: Fri Aug 26, 2005 11:06 pm
by feyd
php cannot do any of that. It is (at this time) a server-side language. Those are client-side functions, so Javascript is the most often used option.

You can have the submission page (after parsing the input verifying validity) can output Javascript to talk to the parent window and close the popup.

Posted: Fri Aug 26, 2005 11:15 pm
by mur
And how would I go about that?

Posted: Fri Aug 26, 2005 11:16 pm
by feyd
window.opener is the parent window that called the popup. self.close() will close the popup. Note: you must do your interactions with the parent before you close the window.

Posted: Fri Aug 26, 2005 11:20 pm
by mur
I know the commands for Javascript, but how to I integrate them into a PHP document?

Thanks

Posted: Fri Aug 26, 2005 11:28 pm
by feyd
you simply output them. Either with echo type functions, or outside of php's processing altogether..

Posted: Fri Aug 26, 2005 11:39 pm
by mur
Is this how it should look?

Code: Select all

echo "<script language="JavaScript">
	self.close();
	</script>";
Because that does not work in my script, nor does it work with separate echos.

Posted: Fri Aug 26, 2005 11:40 pm
by Stewsburntmonkey
You need to escape the quotes around "JavaScript". :)

Code: Select all

echo "<script language=\"JavaScript\">
	self.close();
	</script>";

Posted: Fri Aug 26, 2005 11:55 pm
by mur
So shouldn't this work?

Code: Select all

echo "<script language=\"JavaScript\">
	window.opener.setURL(\"www.google.com\");  
	self.close();
    </script>";
I thought that you could just use the setURL to tell it what page to open.

Posted: Sat Aug 27, 2005 9:05 am
by mur
I also tried using window.opener.location.href which worked in firefox, but not safari, i found a site that said that noted this problem but did not give a solution, does anyone know how to do this.

Right now even closing the opener and opening a new window would be fine.

But window.opener.close(); did not work either

Posted: Sat Aug 27, 2005 9:18 am
by feyd