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 trialBappy Golder
13,449 PointsWhy do we need the name attribute for HTML checkbox?
I understand we need the name attribute for radio buttons. This makes sure that multiple buttons are in the same group.
In the case of check box why do we need the name attribute? Check boxes doesn't need to be grouped so what is the use of the name attribute for them?
1 Answer
John Magee
Courses Plus Student 9,058 PointsForms are submitted, when forms are submitted the elements are processed based on their names.
In addition, it's also useful to use names related to a database where the data is going. Using checkboxes with the same name means your code can easily figure out where the information goes (like, 'interests', or 'pets') in the database
Bappy Golder
13,449 PointsBappy Golder
13,449 PointsThanks John, that makes sense.