HTML | DOM Button formAction Property
The Button formAction property in HTML DOM is used to set or return the value of the formAction attribute of a button. After submission of the form, the formAction attribute is called. The form data is to be sent to the server after submission of the form.
Syntax:
- It is used to return the formAction property.
buttonObject.formAction
- It is used to set the formAction property.
buttonObject.formAction = URL
Property Values:
URL: It is used to specify the URL of the document where the data to be sent after submission of the form.
The possible value of the URL is:
- absolute URL: It points to the full address of a page. For Example www.gfg.org
- relative URL: It is used to point to a file within a webpage. For Example www.geeksforgeeks.org
Return Value: It returns a string value which represents the URL of the form.
Example: This example describes how to set and get the value of formAction property.
<!DOCTYPE html> <html> <head> <title> HTML DOM Button formAction Property </title> </head> <body> <h1>GeeksforGeeks</h1> <h2>DOM Button formAction Property</h2> <form action="/gfg.php" method="post" id="users"> <label for="username"> Username: </label> <input type="text" name="username" id="Username"> <br> <br> <label for="password"> Password: </label> <input type="password" name="password"> <button id="btn" type="submit" formaction="/tryit.php"> Load Changed formAction value </button> </form> <br> <button onclick="myGeeks()"> Submit </button> <p id="GFG"></p> <!-- script to get the updated action page --> <script> function myGeeks() { var x = document.getElementById("btn").formAction; var y = document.getElementById("users").action; document.getElementById("GFG").innerHTML = "formAction changed to " + x + "<br> from " + y; } </script> </body> </html> |
Output:
Before clicking on button:

After clicking on button:

Supported Browsers: The browsers supported by DOM Button formAction Property are listed below:
- Google Chrome
- Internet Explorer 10.0
- Firefox
- Apple Safari
- Opera
Recommended Posts:
- HTML | <button> formaction Attribute
- HTML | DOM Input Image formAction Property
- HTML | DOM Input Submit formAction Property
- HTML | DOM Button value Property
- HTML | DOM Button name Property
- HTML | DOM Button disabled Property
- HTML | DOM Button form Property
- HTML | DOM Button formTarget Property
- HTML | DOM Button type Property
- HTML | DOM Button formMethod Property
- HTML | DOM Button formEnctype Property
- HTML | DOM Button formNoValidate Property
- HTML | DOM Button autofocus Property
- HTML | DOM Input Button name Property
- HTML | DOM Input Button value Property
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



