How to use the submit button in HTML forms?

JavascriptWeb DevelopmentFront End Scripts

Submit button automatically submits a form on click. Using HTML forms, you can easily take user input. The <form> tag is used to get user input, by adding the form elements. Different types of form elements include text input, radio button input, submit button, etc.

Let’s learn about how to use the submit button in HTML forms. It is also created using HTML <input> tag but type attribute is set to button.

You can try to run the following code to use submit button to submit and reset a form. Under the action, attribute add the file, where you want to reach after clicking Submit button. Using get and post method, you can send the values to the PHP file added in action attribute.

Example

Live Demo

<!DOCTYPE html>
<html>
   <body>
      <form action="/new.php">
         Student Name:<br>
         <input type="text" name="sname">
         <br>
         Student Subject:<br>
         <input type="text" name="ssubject">
         <br>
         <input type="submit" value="Submit">
         <input type="reset" value="Reset">
      </form>
   </body>
</html>
raja
Published on 07-Feb-2018 12:22:16
Advertisements