Long Form

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

mur
Forum Newbie
Posts: 21
Joined: Wed Aug 24, 2005 4:01 pm

Post 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
mur
Forum Newbie
Posts: 21
Joined: Wed Aug 24, 2005 4:01 pm

Post 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?
Stewsburntmonkey
Forum Commoner
Posts: 44
Joined: Wed Aug 24, 2005 2:09 pm

Post 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">
mur
Forum Newbie
Posts: 21
Joined: Wed Aug 24, 2005 4:01 pm

Post 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.
mur
Forum Newbie
Posts: 21
Joined: Wed Aug 24, 2005 4:01 pm

Post 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
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
mur
Forum Newbie
Posts: 21
Joined: Wed Aug 24, 2005 4:01 pm

Post by mur »

And how would I go about that?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
mur
Forum Newbie
Posts: 21
Joined: Wed Aug 24, 2005 4:01 pm

Post by mur »

I know the commands for Javascript, but how to I integrate them into a PHP document?

Thanks
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

you simply output them. Either with echo type functions, or outside of php's processing altogether..
mur
Forum Newbie
Posts: 21
Joined: Wed Aug 24, 2005 4:01 pm

Post 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.
Stewsburntmonkey
Forum Commoner
Posts: 44
Joined: Wed Aug 24, 2005 2:09 pm

Post by Stewsburntmonkey »

You need to escape the quotes around "JavaScript". :)

Code: Select all

echo "<script language=\"JavaScript\">
	self.close();
	</script>";
mur
Forum Newbie
Posts: 21
Joined: Wed Aug 24, 2005 4:01 pm

Post 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.
mur
Forum Newbie
Posts: 21
Joined: Wed Aug 24, 2005 4:01 pm

Post 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
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Post Reply