This method requires the normal form HTML codes so if you have not read about them please go to FORMS.
If you have ever wanted to use a form that, after the form is submitted, mails to a specific address and then re-directs the visitor to another page without using cgi or the GeoCities' next-url, then this code will show you how to do that. At the bottom of this page is a test form. It will be sent to me and you will receive a copy at the email address you enter!
NOTE: - The person sending the email must have a browser based email client such as Outlook Express. If they don't then the email will not be sent.
You set up a simple Javascript code in your form page. In the code below, which you can copy and paste to your page, please note the following:
|
<HTML>
<HEAD> <script language="JavaScript" type="text/javascript"> <!-- Hide script from older browsers function DoRedirect(formname) { // put your email address in here formname.action="mailto:anyname@anywhere.com"; // put the redirect url in here absolute or relative urls can be used // example: thankyou.htm location.href="the-next-page"; return true; } //End Hiding --> </script> </HEAD> <BODY> <form method="POST" OnSubmit="JavaScript:return DoRedirect(this);" name="formname" enctype="text/plain"> ..... your other form code here......... </form>
</BODY>
|
formname - The name of this form, e.g. myform.
anyname@anywhere.com - The email address where the form will be sent.
the-next-page - The name of the page that will be displayed next, e.g. thankyou.htm.
your other form code here - In order for the entire form to be sent to you, you must name each form entry in order for the data to be included in the email.
A sample form using this code is below. It will be sent to me and a copy will be sent to the email address you enter so please use your own email to verify that the form is sent.
formname.action="mailto:1st-emailaddress?cc=2nd-emailaddress";
This is a sample of the re-direction form. You can test it by inputting your email address. I will get the form and you will receive a copy. If you wish to use this type of re-direction form then remove the
Note that my form includes a javascript function to clear the Comment box when the visitor clicks their cursor in the box.
NOTE: THE SAMPLE EMAIL FORM CODE BELOW DOES NOT INCLUDE THE 'SEND COPY TO' CODE!
| The Form Code |
|
<script language="JavaScript" type="text/javascript">
<!-- Hide script from older browsers function DoRedirect(formname) { // put your email address in here. formname.action="mailto:your-email-address-here" ; // put the redirect url in here. absolute or relative urls can be used. // I use thankyou.htm but any page name can be used. location.href="your-next-page-address-here"; return true; } //End Hiding --> <!-- function doClear(inputname) { if (inputname.value == inputname.defaultValue) { inputname.value = "" } } //--> </script> <form method="POST" OnSubmit="JavaScript:return DoRedirect(this);" name="formname" enctype="text/plain"> <input type="hidden" name="subject" value="Subject: Testing Email/Re-Direction Javascript Form"> Your Name: <input name="Visitor's Name" type="text" size=20> <p> Your Email Address (copy will be sent to this address): <input name="email" type="text" size=25> <p> Your Comments (box will clear when you click mouse inside it):<br> <textarea cols=25 rows=5 name=comments onFocus="doClear(this)">Enter Your Comments here</textarea> <p> <input type="submit" value="Test Email/Re-Direct Form Code"> </form> |