
- Javascript Basics Tutorial
- Javascript - Home
- Javascript - Overview
- Javascript - Syntax
- Javascript - Enabling
- Javascript - Placement
- Javascript - Variables
- Javascript - Operators
- Javascript - If...Else
- Javascript - Switch Case
- Javascript - While Loop
- Javascript - For Loop
- Javascript - For...in
- Javascript - Loop Control
- Javascript - Functions
- Javascript - Events
- Javascript - Cookies
- Javascript - Page Redirect
- Javascript - Dialog Boxes
- Javascript - Void Keyword
- Javascript - Page Printing
- JavaScript Objects
- Javascript - Objects
- Javascript - Number
- Javascript - Boolean
- Javascript - Strings
- Javascript - Arrays
- Javascript - Date
- Javascript - Math
- Javascript - RegExp
- Javascript - HTML DOM
- JavaScript Advanced
- Javascript - Error Handling
- Javascript - Validations
- Javascript - Animation
- Javascript - Multimedia
- Javascript - Debugging
- Javascript - Image Map
- Javascript - Browsers
- JavaScript Useful Resources
- Javascript - Questions And Answers
- Javascript - Quick Guide
- Javascript - Functions
- Javascript - Resources
How to take user input using HTML forms?
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 the <input> tag, which helps you to take user input using the type attribute. The attribute is used with the form elements such as text input, checkbox, radio, etc.
Example
You can try to run the following code to take user input using HTML Forms:
<!DOCTYPE html> <html> <body> <head> <title>HTML Forms</title> </head> <p>Add your details:</p> <form> Student Name:<br> <input type="text" name="name"> <br> Student Subject:<br> <input type="text" name="subject"> <br> Rank:<br> <input type="text" name="rank"> </form> </body> </html>
Above, you can see the following two attributes:
- type
Indicates the type of input control and for text input control it will be set to text - name
Used to give a name to the control which is sent to the server to be recognized and get the value.
- Related Articles
- How do we take password input in HTML forms?
- Make JavaScript take HTML input from user, parse and display?
- How to clear all the input in HTML forms?
- Take Matrix input from user in Python
- How do we reset all the input fields in HTML forms?
- How to take input in Python?
- How do we send an email using HTML forms?
- Execute a script when the element gets user input in HTML?
- How to get Input from the User in Golang?
- How to use tables to structurize forms in HTML?
- How to create input Pop-Ups (Dialog) and get input from user in Java?
- How do we upload external file on a website using HTML forms?
- How to allow multiple file uploads in HTML forms.
- What HTML forms are and how to use them?
- How to use the submit button in HTML forms?

Advertisements