Javascript examples for DOM HTML Element:Form
The action property sets or gets the action attribute in a form, which controls where to send the form data when a form is submitted.
Set the action property with the following Values
Value | Description |
---|---|
URL | Sets where to send the form data when the form is submitted. |
Possible values:
A String, representing the URL of where to send the form-data when a form is submitted
The following code shows how to change the action URL of a form:
<!DOCTYPE html> <html> <body> <form id="myForm" action="nothing.asp"> First name: <input type="text" name="fname" value="Donald"><br> Last name: <input type="text" name="lname" value="Duck"><br> <input type="submit" value="Submit"> </form>// w ww . ja v a 2s . c o m <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() { document.getElementById("myForm").action = "#"; document.getElementById("demo").innerHTML = "The value of the action attribute was changed to #."; } </script> </body> </html>