Click to See Complete Forum and Search --> : Form Submission (Please Help!)


susha
03-13-2003, 07:24 AM
I want to create a form that will send me the data through E-mail and then take the user to another HTML page. Can this be achieved with HTML and JavaScript?

Example:

<!------------ --------------->
<html>
<body>
<form action="MAILTO:susha@canada.com" method="post" enctype="text/plain">

<h3>This form sends an e-mail to an E-mail address specified.</h3>
Name:<br>
<input type="text" name="name"
value="yourname" size="20">
<br>
Mail:<br>
<input type="text" name="mail"
value="yourmail" size="20">
<br>
Comment:<br>
<input type="text" name="comment"
value="yourcomment" size="40">
<br><br>
<input type="submit" value="Send">
<input type="reset" value="Reset">

</form>
</body>
</html>
<!------------ --------------->

The above code will send an E-mail to me. How can I take the user to another page after he clicks SUBMIT? For example, http://www.EnglishBest.com or a THANKS! page.

Expecting your help,

Susha John.

khalidali63
03-13-2003, 07:29 AM
I don't think you can do this using the logic you mentioned,since once submit is triggered the rest of the page will be out of scope,
You will need to serverside scripting or may be some other logic.

Cheers

Khalid

susha
03-13-2003, 07:32 AM
Thanks a lot, Khalid.

I don't want to use server side scripting. Any other way to achieve this?

pyro
03-13-2003, 07:32 AM
This seems to work...

<html>
<head>

<script language="javascript" type="text/javascript">

function forwardpage()
{
window.location.href = "http://www.yahoo.com";
}

</script>

</head>
<body>
<form action="mailto:susha@canada.com" method="post" enctype="text/plain" onsubmit="forwardpage()">

<h3>This form sends an e-mail to an E-mail address specified.</h3>
Name:<br>
<input type="text" name="name"
value="yourname" size="20">
<br>
Mail:<br>
<input type="text" name="mail"
value="yourmail" size="20">
<br>
Comment:<br>
<input type="text" name="comment"
value="yourcomment" size="40">
<br><br>
<input type="submit" value="Send">
<input type="reset" value="Reset">

</form>
</body>
</html>

khalidali63
03-13-2003, 07:45 AM
Interesting pyro,Actually it does seem to work,
Logically it seesm wrong though,

This why,

once window.location.href is triggered the previous page should have been out of scope,hence reaching at the point to triggere action would not be possible,But it works so

Why am I complaining..

:D

Awsome work around.

Khalid

pyro
03-13-2003, 07:48 AM
I agree. I expected to have to set a Timeout or something. I decided to try it that way first and it worked... hmm... ;)

Cheers!

khalidali63
03-13-2003, 08:12 AM
try it with NS6+

:p

Khalid

pyro
03-13-2003, 08:19 AM
I don't have any email set up with Netscape 7. It does, however pop up Netscape Composer, so it seems like it would work. Doesn't it?

khalidali63
03-13-2003, 09:06 AM
No,It does not look like ti works for ns

I have just setup an email account for this testing,I get the mail but no redirection/forwarding

Khalid

pyro
03-13-2003, 09:57 AM
I tried in Mozilla 1.2 and what it does in that is pops up the email in my Outlook, I then would have to manually hit send, and there is no re-direct. So, it was probably an IE bug... :p

Anyway, like Khalid originally mentioned, server side coding is going to be your best bet for cross-browser compatibility - and you won't get any warning messages...