Skip to content

Form action JavaScript | attribute

  • by

JavaScript Form action attribute used in <form> tag to specify a URL that will process the form submission. The action attribute specifies where to send the form data when a form is submitted.

Form action JavaScript

Simple example code “Submit” button and the form data will be sent to a page on the server called “action_page.php”.

<!DOCTYPE html>
 <form action="/action_page.php" method="get">
  <label for="fname">First name:</label>

  <input type="text" id="fname" name="fname"><br><br>
  <label for="lname">Last name:</label>
  <input type="text" id="lname" name="lname"><br><br>
  <input type="submit" value="Submit">


Form action JavaScript attribute

Form action Property

The action property sets or returns the value of the action attribute in a form. Change the action URL of a form:

Return the action property:


Set the action property:

formObject.action = URL
document.getElementById("myForm").action = "/action_page.php";

Do comment if you have any doubts or suggestions on this Js HTML form topic.

Note: The All JS Examples codes are tested on the Firefox browser and the Chrome browser.

OS: Windows 10

Code: HTML 5 Version

Leave a Reply

Your email address will not be published. Required fields are marked *