Set the name of the form the element belongs to in HTML?


Use the form attribute in HTML to set the name of the one or more form the element belongs to in HTML.

Example

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

<!DOCTYPE html>
<html>
   <body>
      <form action = "" method = "get" id = "myform">
         SubjectID: <input type = "number" name = "subid"><br>
         Subject Name: <input type = "text" name = "subname"><br>
         Total Students: <input type="number" name = "stcount"><br>
      </form>
      <button type = "submit" form = "myform" value = "Submit">Click</button>
   </body>
</html>

Updated on: 30-May-2020

84 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements