Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialRob Harding
4,128 Pointsname VS value
What's the difference between name and value? I think i remember using PHP and using the name when you would get $_POST info
1 Answer
Geoff Parsons
11,679 PointsThe name of the field will be how you reference it in the $_POST
(php) or params
(rails) hashes server-side.
The value is a pre-defined value for the field; users can change the value (if it's not a hidden field) but if they don't it will be the value sent when they submit the form.
Rob Harding
4,128 PointsRob Harding
4,128 Pointswhat about check boxes and radio buttons?
Ran Yehushua
5,908 PointsRan Yehushua
5,908 PointsTo answer your comment on this response Rob:
With text, email, password, etc... inputs - the value returned to the server-side is whatever the user enters into the input field.
With radio buttons and check boxes, the value(s) is/are selected from a pre-defined collection of options, and so each option (radio or checkbox) has a 'name' associated with it for the server side code to identify as well as the defined 'value' attribute that will act as the value that the server side code assigns to the name (rather than a user defined value in the example of text, email, password, etc...)