- HTML Tutorial
- HTML - Home
- HTML - History and Evolution
- HTML - Overview
- HTML - Editors
- HTML - Basic Tags
- HTML - Elements
- HTML - Attributes
- HTML - Formatting
- HTML - Headings
- HTML - Paragraphs
- HTML - Quotations
- HTML - Comments
- HTML - Phrase Tags
- HTML - Meta Tags
- HTML - Style Sheet
- HTML - CSS Classes
- HTML - CSS IDs
- HTML - Images
- HTML - Image Map
- HTML Tables
- HTML - Tables
- HTML - Headers & Caption
- HTML - Table Styling
- HTML - Table Colgroup
- HTML - Nested Tables
- HTML Lists
- HTML - Lists
- HTML - Unordered Lists
- HTML - Ordered Lists
- HTML - Definition Lists
- HTML Links
- HTML - Text Links
- HTML - Image Links
- HTML - Email Links
- HTML - Iframes
- HTML - Blocks
- HTML Backgrounds
- HTML - Backgrounds
- HTML Colors
- HTML - Colors
- HTML - RGB
- HTML - HEX
- HTML - HSL
- HTML Forms
- HTML - Forms
- HTML - Form Attributes
- HTML - Form Control
- HTML - Input Attributes
- HTML Media
- HTML - Video Element
- HTML - Audio Element
- HTML - Embed Multimedia
- HTML Header
- HTML - Head Element
- HTML - Adding Favicon
- HTML - Javascript
- HTML Layouts
- HTML - Layouts
- HTML - Layout Elements
- HTML - Layout using CSS
- HTML - Responsiveness
- HTML - Symbols
- HTML - Emojis
- HTML - Style Guide
- HTML Graphics
- HTML - SVG
- HTML - Canvas
- HTML APIs
- HTML - Geolocation API
- HTML - Drag & Drop API
- HTML - Web Workers API
- HTML - WebSocket
- HTML - Web Storage
- HTML - Server Sent Events
- HTML Miscellaneous
- HTML - MathML
- HTML - Microdata
- HTML - IndexedDB
- HTML - Web Messaging
- HTML - Web CORS
- HTML - Web RTC
- HTML Demo
- HTML - Audio Player
- HTML - Video Player
- HTML - Web slide Desk
- HTML Tools
- HTML - Velocity Draw
- HTML - QR Code
- HTML - Modernizer
- HTML - Validation
- HTML - Color Code Builder
- HTML References
- HTML - Tags Reference
- HTML - Attributes Reference
- HTML - Events Reference
- HTML - Fonts Reference
- HTML - ASCII Codes
- ASCII Table Lookup
- HTML - Color Names
- HTML - Entities
- MIME Media Types
- HTML - URL Encoding
- Language ISO Codes
- HTML - Character Encodings
- HTML - Deprecated Tags
- HTML Resources
- HTML - Quick Guide
- HTML - Useful Resources
- HTML - Color Code Builder
- HTML - Online Editor
HTML - formaction Attribute
The HTML formaction attribute is used to specify an URL of the file that will process the input controls and redirect to a different page when the form is submitted.
It overrides the action attribute of the form element. It is used with image and submit type of input elements and also used with <button> elements.
For example, if the image type input element has the formaction attribute present, when the user clicks on an image, it will redirect to a different page. And if the user submits the form, it will redirect to the URL specified in the action attribute of the <form> element.
Syntax
Following is the syntax for HTML formaction attribute −
<tag formaction = "URL"></tag>
Example
In the following example, we are going to use the HTML formaction attribute with input type=submit.
<!DOCTYPE html> <html lang="en"> <head> <title>HTML 'formaction' attribute</title> </head> <body> <!--HTML 'formaction' attribute--> <p>Example of the HTML 'formaction' attribute</p> <form action="html logo.html" method="get"> <label for="">Username</label> <input type="text"> <br> <br> <label for="">Password</label> <input type="password"> <br> <br> <input type="submit" value="Login" formaction="welcome.html"> </form> </body> </html>
When we run the above code, it will generate an output consisting of the input field filled with data along with a click button displayed on the webpage.
Example
Considering the another scenario, where we are going to use the formaction attribute with the button element.
<!DOCTYPE html> <html lang="en"> <head> <title>HTML 'formaction' attribute</title> </head> <body> <!--HTML 'formaction' attribute--> <p>Example of the HTML 'formaction' attribute</p> <form action="welcome1.html" method="get"> <label for="">Name</label> <input type="text"> <br> <br> <label for="">Email</label> <input type="email"> <br> <br> <label for="">Mobile</label> <input type="number"> <br> <br> <button>Submit</button> <button formaction="welcome.html">Submit to another page</button> </form> </html>
On running the above code, the output window will pop up displaying the input field filled with data along with a click button on the webpage.
Example
Let's look at the following example, where we are going to use the formaction attribute with the input type=image.
<!DOCTYPE html> <html lang="en"> <head> <title>HTML 'formaction' attribute</title> </head> <body> <!--HTML 'formaction' attribute--> <p>Example of the HTML 'formaction' attribute</p> <h3>Click on the below image to redirect different page</h3> <form action="https://www.tutorialspoint.com/static/images/logo.png?v3" method="get"> <input type="image" formaction="download.png" src="https://www.tutorialspoint.com/static/images/logo.png?v3" width="200"> <button>Submit</button> <p>Click on the above submit button to redirect different page.</p> </form> </html>
When we run the above code, it will generate an output consisting of the text , image along with a click button on the webpage.
To Continue Learning Please Login
Login with Google