Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simultaneous email AND redirect from FORM...

Status
Not open for further replies.

ebrowning

Programmer
Feb 6, 2001
6
GB
Hi,

I have a form which requires validation. If it passes, the form contents are emailed to me AND it redirects to another page, much like a page which asks for your email address before allowing you access to the goodies inside the site.

My validation is fine using a function, but I'm having trouble mailing the form and redirecting the page at the same time.

My form tag for emailing would be:

<form onSubmit=&quot;return validateform(this)&quot; name=&quot;form1&quot; method=&quot;post&quot; action=&quot;mailto:me@myaddress.com&quot; enctype=&quot;text/plain&quot;>

,and my form tag for redirecting would be:

<form onSubmit=&quot;return validateform(this)&quot; name=&quot;form1&quot; method=&quot;get&quot; action=&quot;access_granted.htm&quot;>

,but I need a method of incorporating the two actions. Any help greatly appreciated.

BDC.


 
I don't know if this will work but try it anyway. use the first form tag and in the validation function if everything is validated then execute location.href = &quot;access_granted.htm&quot;;
 
Thanks Klae, but I've tried this already. The location.href=&quot;access_granted&quot; doesn't seem to work within the validation function before the final &quot;return true&quot; statement.

:-(
BDC.
 
Hi,

First, you have to give different names to your 2 forms and after, I don't know if it will works 'cose I don't try it but try to put this at the end of your validation function :

document.myForm1.submit();
document.myForm2.submit();

Hope that it will solve your problem
 
Sorry SeAL, I didn't explain very well.

I have only one form, I just gave two different examples for the different actions I require for the same form.

I have been given some code to place at the end of my validation function:

myTimer = window.setTimeout(&quot;window.location.replace('access_granted.htm');&quot;, 5000);

This delays the redirect for 5 seconds while the form is submitted. This method works, but now I have a new problem:

In IE, a message box appears on Submit &quot;This form is being submitted by email...&quot;. If the user clicks CANCEL, the redirect still sends you to the new page but no email is sent!!

If I can't get this to work, I might try putting the information into a database, but I'm not sure of the JavaScript to do this.

Any comments greatly appreciated - Many thanks,

BDC
 
I've decided not to use E-mail, and instead I've created an access database with ASP pages to store user details.

Thanks again for your help.

BDC :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top