Javascript examples for DOM HTML Element:Input Submit
The formAction property sets or gets the formaction attribute of a submit button, which identifies the URL of the file that will process the input control when the form is submitted.
The formaction attribute overides the action attribute of the <form> element.
Set the formAction property with the following Values
Value | Description |
---|---|
URL | Sets the URL of the file that will process the input control |
A String, representing the URL for where to send the form-data
The following code shows how to get the URL of the file that will process the input control when the a form is submitted:
<!DOCTYPE html> <html> <body> <form> First name: <input type="text" name="fname" value="Mary"><br> Last name: <input type="text" name="lname" value="Bond"><br> <input type="submit" id="mySubmit" formaction="#" value="Submit"> </form>// w w w .jav a 2s. c om <p id="demo"></p> <button onclick="myFunction()">Test</button> <script> function myFunction() { document.getElementById("mySubmit").formAction = "/action_page2.php"; document.getElementById("demo").innerHTML = "The value of the formaction attribute was changed to 'action_page2.php'."; } </script> </body> </html>