What is the use of name attribute in <input> element in forms of html | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

What is the use of name attribute in <input> element in forms of html

23rd Jul 2018, 8:47 AM
Dare$devil
Dare$devil - avatar
5 Answers
+ 3
Hi, Using the same name attribute you are making a set of inputs when the input type is radio or checkbox So if you make three radio inputs with the same name, you will be able to choose only one Hope it helps you
23rd Jul 2018, 9:01 AM
Guillem Padilla
Guillem Padilla - avatar
+ 2
Name is also useful when you want to do form validation with Php
23rd Jul 2018, 9:09 AM
Paul Grasser
Paul Grasser - avatar
+ 2
The value is the value of the input haha, The result of submitting is: "Name"=Value If you make a text type input, with name="username", if you put a value as attribute, then the input will have a predefined value, but the user can change it because value is the user input, the result should be Name of input User input username = Value
23rd Jul 2018, 9:29 AM
Guillem Padilla
Guillem Padilla - avatar
0
then what's the use of value
23rd Jul 2018, 9:23 AM
Dare$devil
Dare$devil - avatar
0
<input type = "password" name="password"> This is inside a form with method POST PHP: if ($_POST["password"] =="lol"){ echo "Password correct!"; }
23rd Jul 2018, 9:54 AM
Paul Grasser
Paul Grasser - avatar