0

[SOLVED] name=“” vs value=“”

What’s the difference?

29th Jul 2019, 11:40 AM
7Pineapple
7Pineapple - avatar
4 Answers
+ 2
Name is what is displayed, value is what it is. Usually you set the value to be a different aspect of the named object. e.g. amount of fruit: name = apples, value = 6, name = oranges, value = 3 weather report: name = London, value = rainy, name = Paris, value = sunny
29th Jul 2019, 11:47 AM
Rincewind
Rincewind - avatar
+ 7
The name can be any, serves to bind and combine the fields of one type. The value in contrast to the name is visible to the user and it is sent to the server.
29th Jul 2019, 11:45 AM
Anna/ĐĐœŃ
Anna/ĐĐœŃ - avatar
+ 2
Anna's description is better and more accurate than mine, please take a look at this link as well: https://teamtreehouse.com/community/whats-the-difference-between-the-value-and-name-attribute
29th Jul 2019, 12:35 PM
Rincewind
Rincewind - avatar
0
so they’ve written <input type=“checkbox” name=“gender” value=“1”/> Male but only ‘Male’ is what’s visible to the user, so why write ‘gender’ in the name element? It doesn’t seems to be doing anything.
29th Jul 2019, 11:56 AM
7Pineapple
7Pineapple - avatar