Computer >> Computer tutorials >  >> Programming >> HTML

Set where to send the form-data when a form is submitted in HTML?


Use the formaction attribute in HTML to set where to send the form-data when a form is submitted in HTML.

Example

You can try to run the following code to implement the formaction attribute −

<!DOCTYPE html>
<html>
   <head>
      <title>HTML formaction attribute</title>
   </head>
   <body>
      <form action = "/new1.php" method = "get">
         Student name: <input type ="text" name = "name"><br>
         Student Subject: <input type = "text" name = "subject"><br>
         <button type = "submit">Submit</button><br>
         <button type = "submit" formaction = "/new2.php">Another page</button>
      </form>
   </body>
</html>