How to use formaction attribute in HTML ?
In this article, we will learn how to use the formaction attribute in HTML. Basically, the information attribute is used to define where to send the data of the form after submitting the form the working of formaction will begin. It overrides the feature of the action attribute of the<form> element.
Why do we use formaction Attribute?
Lets suppose, we have two submit buttons in one form and both the buttons work separately and redirect to another URL of the page. Both the button send data to different pages.
Values: It contains the physical address of the location of the file where to send the form data.
Two passible values are –
- absolute URL: It points to the full address of a page. For example “www.geeksforgeeks.org/data-structure”
- relative URL: It is used to point to a file within a webpage. For example gfg.php
Example:
HTML
<!DOCTYPE html> < html > < head > < title > How to use formAction Attribute im HTML ? </ title > </ head > < body style = "text-align:center;" > < h1 > GeeksForGeeks </ h1 > < h2 > How to use formAction Attribute in HTML? </ h2 > < form method = "get" target = "_self" > Username:< input type = "email" name = ename "">< br >< br > Password < input type = "password" name = "passwrd" >< br > < input type = "submit" value = "submit for Java User" formaction = < input type = "submit" value = "submit for python User" formaction = </ form > </ body > </ html > |
Output
- After Click on the Submit for Java user Button:
- After Click on the Submit for python user Button:
Please Login to comment...