Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

HTML | DOM Button formAction Property

  • Last Updated : 18 Jul, 2019

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.


  • It is used to return the formAction property.
  • 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
  • relative URL: It is used to point to a file within a webpage. For Example

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 DOM Button formAction Property
    <h2>DOM Button formAction Property</h2>
    <form action="/gfg.php" 
        <label for="username">
        <input type="text" 
        <label for="password">
        <input type="password" 
        <button id="btn" 
            Load Changed formAction value
    <button onclick="myGeeks()">
    <p id="GFG"></p>
    <!-- script to get the updated action page -->
        function myGeeks() {
            var x = 
            var y = 
            document.getElementById("GFG").innerHTML = 
              "formAction changed to " + x + "<br> from " + y;

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

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!