action (HTML attribute)
Example
Theaction
attribute here tells the browser to send the form data
to a form-handling PHP page (which will presumably convert the form data
to something email-friendly).<form action="form-to-email.php" method="post" accept-charset="windows-1252"> <div> <label for="txtname">Name:</label> <input type="text" name="txtname" id="txtname"/> </div> … </form>
Description
A form is
useless without having some kind of processing after the
form is submitted. The action
attribute is used to inform the browser what page (or script) to call once
the "submit" button is pressed.
Value
A URL, which may be in the same directory on the server, another directory on the server (for example a shared CGI folder that has various form-processing scripts) or even a page/script on an entirely separate server (perhaps a free form-handling service, if you do not have the facilities or necessary scripting skills to process form data for yourself).
Compatibility
| IE | 5.5 | Full |
|---|---|---|
| 6.0 | Full | |
| 7.0 | Full | |
| Firefox | 1.0 | Full |
| 1.5 | Full | |
| 2.0 | Full | |
| Safari | 1.3 | Full |
| 2.0 | Full | |
| 3.0 | Full | |
| Opera | 9.2 | Full |
| 9.5 | Full |
Causes no compatibility issues. It has excellent support across all tested browsers.
In
addition to specifying a URL, some browsers will allow understand a mailto
URL which will then open the email client on the computer and generate a
new message which can then be sent by the user, but this is not a
particularly slick way of managing form data - you are
much better off using server-side processing to ensure a consistent
behavior across browsers.
User-contributed notes
Add a note
To post a note on this topic, please log in with your SitePoint username and password. If you don't have an account yet, you can create a new account for free.

