Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.
Arikaturika Tumojenko8,897 Points
Understanding the values for the "name" attribute.
Are all the values used until now in the video pre estabilished or we could give the attribute name any value we want (<input type="text" id="name" name="threehouse_form"> for example)?
Alexander PeschelFront End Web Development Techdegree Student 11,181 Points
The first element in the document with an ID matching the value of the for attribute is the labeled control for this label element.https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input
The name attribute is for fetching values after submitting the form.
Jonathan GrieveTreehouse Moderator 90,845 Points
Yes generally we can give the name attribute any value we want.
There are one or 2 caveats in the way the attribute is used, For example the name attribute works with the label "for" attribute and the names must be the same but to my knowledge there's no limit to what values you could feasibly use. :p-)
Kevin Korte28,111 Points
I think Jonathan is right, as long as the name attribute is a string value, you should be able to make it whatever you want. You'll just want your label for attribute to match as he said.
You'll just need a matching attribute to grab the form data on the server side.