Forum Moderators: coopster
I have no problem getting it set up so that they can e-mail and subit their address...my issue is this:
the client *does not* want the end user to leave the page they're on. They want the person to submit the e-mail address, have a popup window that says "Thanks!", and have the user return to the same page they were at, with the form cleared.
I'm having sever issues trying to find how this works. I can make a popup on submit - but it returns to a blank page when you close the window. If I try to make it so it returns to the current page on window close, the e-mail is still in the form - and if I try to set it to clear, no email comes through.
Could anyone help me out on this? Thanks in advance :[smilestopper])
onSubmit="popWin('thanks.php?email='+ escape(this.email.value));return false;" where popWin is a js function that opens the popup and email is the name of the email text box. The email address will be $_GET variable in the page you pop.
You could simply (a) accept the form submission, and (b) return to the original page (default values) and (c) trigger the Javascript popup if the data is validated.
i.e.
(included in form.php)
<form action="<?=$_SERVER["SCRIPT_NAME"]?>" method=post> <input type="hidden" name="dopop" value=1 /> ... the rest of the form ... then when the form is submitted, it posts the data back to the server, and returns to the same page, i.e.
(also included in form.php):
<? if ($_POST["dopop"]) { ... validate and process form data ... } ?> and, if the form validates:
<? if ($validated) {?> <script type="text/javascript"> ...popup code... </script> <? }?> If the form data validates, the form page will be returned to its default values, the form data will have been processed, and Javascript will pop up the "thanks" window for a successful submission.
If the form data does not validate, you can stop the process right there and re-populate the form with the POST data along with your note about what needs to be corrected. The Javascript popup need not be triggered. The user corrects the form and re-submits, and on you go.