Re: Form question
by "Bert Doorn" <bert(at)betterwebdesign.com.au>
|
Date: |
Wed, 3 Oct 2001 11:10:28 +0800 |
To: |
"Matthew Ohlman" <matthew(at)ohlman.com> |
Cc: |
"HWG Basics" <hwg-basics(at)hwg.org> |
References: |
ohlman |
|
todo: View
Thread,
Original
|
|
Hi Matthew
> Hi all! What I would like to know is if there is a way (using HTML,
> JavaScript) to do the following in a form when the submit button is
pushed:
> 1.) Email the form input to me
> 2.) Rederict user to another page
This is a frequently asked question (FAQ)
Yes, there is a way to do it, but it's the "poor man's version" of
processing forms. The general consensus, particularly for business sites,
is that it's better to use something other than HTML+JavaScript for this
purpose. A perl/cgi, PHP or ASP script, running on the server, rather than
using "tricks" on the browser side, which will not always work.
But if you "have to" do it with HTML and JavaScript..... You CAN specify
mailto: (followed by your email address) as the form's action:
<.form action="mailto:matthew(at)ohlman.com" method="post>
form contents here
<./form>
JavaScript redirect will not work if JavaScript is not available in the
browser. But you CAN do it this way:
<.input type="submit" onclick="JavaScript:location='thankyou.html';">
The user will most likely get a security warning from their browser and may
decide not to proceed. In addition, if there is no email program attached
to their browser, the message simply will go nowhere. It would not work for
me in Netscape for instance, as I have not set up my email account in
Netscape...
By using a "proper" form mail script, you overcome the problem of it not
working for browsers that have no email program attached to them or have
JavaScript disabled. The server takes care of both the mailing and the
redirection. Matt's Form Mail
(http://www.worldwidemart.com/scripts/formmail.shtml) is a general purpose
script which works on just about any server and many hosts actually include
it (or something similar) in their hosting accounts.
HTH
--
Bert Doorn, Web Developer
http://www.betterwebdesign.com.au/
Beginners Web Design Tutorial
http://www.bwdzine.com/bwdt/
HTML: hwg-basics mailing list archives,
maintained by Webmasters @ IWA