+ 4

What is different of "id" and "name" attributes in "input" elements?

<input id="user" name="username" type="text" /> I don't know what function

6th Nov 2016, 8:06 AM
Satria Manggala Jati (GaLa ORG)
Satria Manggala Jati (GaLa ORG) - avatar
2 Respostas
+ 2
To get the result of your form, you have to get the variable using the name (for instance, using PHP and the POST method, it will be in $_POST["username"]) but if you want to put a label, to use some CSS or to verify the value with JS, you will use the id.
6th Nov 2016, 8:43 AM
Pierre Varlez
Pierre Varlez - avatar
+ 2
"id" is used to decorate(css) or script(js) the particular tag while "name" is used to get the data to the server from the client.. name is also useful to make one set of many inputs, for example; <input type=radio name="one"> <input type=radio name="one"> they both should match otherwise it will not work together for the same input
15th Nov 2016, 5:19 AM
Sainze Hang
Sainze Hang - avatar