action property (form)
Sets or retrieves a form processing agent. With this property you can set an URL to call when the form is sent.
Use it together with the method property that specifies the way to send.
Syntax:
You can find the related objects in the Supported by objects section below.
This property is read/write.
HTML page for this property: action |
Possible values:
String that sets or retrieves the URL to call. It can be an absolute or relative path as well. Relative paths are relative to the base URL. The base URL is the location of the current document, but it can be overridden by the base tag.
Default: this property has no default value.
Example HTML code 1:
This example illustrates the use of the action attribute:
|
||||
Submitting data to a server: <br /> <form action="http://example.com/sample.php" method="post"> <input name="email" type="text" size="30" value="Enter your e-mail!" /> <input type="submit" value="Send Your email address" /> </form> <br /><br /> Submitting data to a server using e-mail: <br /> <form action="mailto:support@example.com" method="get" style="border:1px solid #999999;"> <input name="username" type="text" size="30" value="Enter your name!" /> <br /> <input name="location" type="text" size="30" value="Enter your location!" /> <br /> <input type="submit" value="Send Data as email" /> </form> |
||||
|
||||
Did you find this example helpful?
|
Example HTML code 2:
This example shows how to change the action property of a form to search with different search engines:
|
||||
<head> <script type="text/javascript"> function Search () { var form = document.getElementById ("myForm"); var radios = document.getElementsByName ("engine"); var engine = "live"; for (var i=0; i < radios.length; i++) { if (radios[i].checked) { engine = radios[i].value; break; } } switch (engine) { case "live" : form.action = "http://search.live.com/results.aspx"; break; case "google" : form.action = "http://www.google.hu/search"; break; } form.submit (); } </script> </head> <body> <form id="myForm" method="get"> <input name="q" type="text" size="30" value="What to find" /> <label for="engine_live">live</label> <input type="radio" name="engine" id="engine_live" value="live" checked="checked" /> <label for="engine_google">google</label> <input type="radio" name="engine" id="engine_google" value="google" /> <input type="submit" onclick="Search ();" value="Search!" /> </form> </body> |
||||
|
||||
Did you find this example helpful?
|
Supported by objects:
HTML elements:
Related pages:
External links:
User Contributed Comments