Re: closing window after submit
| From: | DAve Goodrich | Date: | Fri, 29 Jun 2001 21:23:50 +0000 |
| Subject: | Re: closing window after submit | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-55656@lists.php.net to get a copy of this message | ||
on 6/28/01 3:57 PM, Richard Kurth at rkurth@pacifier.com wrote:
> I have a form that is in a pop up window it has an image for a submit
> button how can I close the pop up after submitting. I know I can do it
> with javascript with a standard submit button. but how can I do it when
> I use an image for a submit button
>
>
> <form method="post" action="<?echo $PHP_SELF;?>">
> <input type="TEXT" name="email" size="30"
> maxlength="50">
> <input type="image" src="fm_sub.gif" width="71"
> height="11" border="0">
>
> Best regards,
> Richard
> mailto:rkurth@pacifier.com
>
Set a hidden variable within the form, then have PHP check the value when
the page reloads. if the variable is set, have PHP add a JavaScript line to
close the window immediately. !!! Note my syntax may be incorrect.
<html><head><title>Test page<title>
<script language='Javascript'>
<?php
// if we have been here before, my_hidden_var = 1,
// output some JavaScript to close the window.
if ( $HTTP_POST_VARS["my_hidden_var"] == 1 ){print "window.close();"}
?>
</script>
</head>
<body>
<form method="post" action="<?echo $PHP_SELF;?>">
<input type="TEXT" name="email" size="30"
maxlength="50">
<input type="image" src="fm_sub.gif" width="71"
height="11" border="0">
<!--add a hidden variable to tell PHP we have been here before"--->
<input type="hidden" name="my_hidden_var" value=1>
I believe this will do what you want. If the form has been submitted then
the value of my_hidden_var should cause PHP to insert the correct JavaScript
to close the window.
Is that what you are looking for?
I think a cleaner solution would be to have PHP check the value of the
my_hidden_var and redirect to a thank you page. This could be set to time
out and close if you wanted, or offer a validation step as well.
DAve
--
Dave Goodrich
Director of Interface Development
Reality Based Learning Company
9521 NE Willows Road, Suite 100
Redmond, WA 98052
Toll Free 1-877-869-6603 ext. 237
Fax (425) 558-5655
daveg@rblc.com
http://www.rblc.com