Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • HTML Tutorial
  • HTML Exercises
  • HTML Tags
  • HTML Attributes
  • Global Attributes
  • Event Attributes
  • HTML Interview Questions
  • HTML DOM
  • DOM Audio/Video
  • HTML 5
  • HTML Examples
  • Color Picker
  • A to Z Guide
  • HTML Formatter
Open In App
Next Article:
HTML | <input> formaction Attribute
Next article icon

How to use formaction attribute in HTML ?

Last Updated : 23 Jul, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report

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? 

Let's suppose, we have two submit buttons in one form and both the buttons work separately and redirect to another URL of the page. Both buttons send data to different pages.

Values: It contains the physical address of the location of the file where to send the form data. 

Two possible 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: In this example, we will use the formaction attribute in HTML

HTML
<!DOCTYPE html> <html>    <head>     <title>         How to use formAction Attribute in 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= "https://www.geeksforgeeks.org/courses/java-backend-live">          <input type="submit"                 value="submit for python User"                formaction= "https://www.geeksforgeeks.org/python-programming-language/">     </form> </body>  </html> 

Output:

  • After Click on the Submit for Java user Button: 

  • After Click on the Submit for Python user Button:
2



Next Article
HTML | <input> formaction Attribute

M

manaschhabra2
Improve
Article Tags :
  • Web Technologies
  • HTML
  • Web technologies
  • HTML-Attributes
  • HTML-Questions

Similar Reads

  • HTML | <input> formaction Attribute
    The HTML <input> formaction Attribute is used to specify where to send the data of the form. After submission of the form the formaction attribute called. The form data is to be sent to the server after submission of the form. It overrides the feature of the action attribute of an <form>
    1 min read
  • HTML | input formmethod Attribute
    The HTML <input> formmethod Attribute is used to specify the HTTP method for sending form-data to the action URL. This attribute is used to override the method attribute of the <form> element. Syntax: <input formmethod="get | post"> Attribute Values: get: It has a default value. In
    2 min read
  • HTML | <button> formaction Attribute
    The HTML <button> formaction Attribute is used to specify where to send the data of the form. After submission of form the formaction attribute called. The form data is to be sent to the server after submission of form. It overrides the feature of the action attribute of an <form> elemen
    1 min read
  • HTML <input> form Attribute
    The HTML <input> form Attribute is used to specify interactive input fields for web-based forms. A form can contain multiple input fields to accept inputs from the users. It is the most powerful element in HTML. Syntax: <input form="form_id"> Attribute Value: This attribute contains a si
    1 min read
  • HTML | <input> formtarget Attribute
    The HTML <input> formtarget attribute is used to specify the name or a keyword which indicates where to display the response after submitting the form. This attribute overrides the target attribute of <form> element. Syntax: <input formtarget="_blank|_self|_parent|_top|framename">
    1 min read
  • How to use placeholder attribute in HTML ?
    We know that the placeholder attribute is used to define a hint of what value has to be entered on the input and textarea field. This attribute is used for a better understanding of form structure. It contains a string value that represents the short hint that describes the expected value of an inpu
    1 min read
  • HTML | <form> name Attribute
    The HTML <form> name Attribute is used to specify the name of a form Element. It is used to reference the form-data after submitting the form or to reference the element in a JavaScript. Syntax: <form name="name"> Attribute Values: It contains a single value name which describes the name
    1 min read
  • HTML <select> form Attribute
    The form attribute in HTML <select> specifies the dropdown list's associated form, identified by the id attribute of a <form> element. Syntax: <select form="form_id">Attribute Values: Name Description value <option> value is sent on form submission, text displays in dropdown.
    1 min read
  • How to use the required attribute in HTML ?
    HTML introduced many features for the enhancement of forms. Before the required attribute was introduced, we use JavaScript code to mandatory a specific input field must be filled out before submitting the form. Now, this process is easy just by using the required attribute. This attribute is used t
    1 min read
  • HTML | <input> formenctype Attribute
    The HTML <input> formenctype Attribute is used to specify how to form-data encoded when submitting the form into the server. This attribute works with method="post". This attribute overrides the enctype attribute of the <form> element. Syntax: <input formenctype="value"> Attribute
    1 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences