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 trial

HTML

Louise Iyengar
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Louise Iyengar
Full Stack JavaScript Techdegree Graduate 21,991 Points

How would a number of checkbox input fields with the same name attribute value be processed by the server?

In an HTML form, I thought name=value pairs had to be one to one when GET or POSTed to a server-side program -- one name, one value. How come Nick has all checkboxes name= "user_interest" in the checkbox video for HTML Forms. How would the various values be processed if there is only one name?

1 Answer

Steven Parker
Steven Parker
229,644 Points

If only one box is checked, it would work much like a radio button group, and the name would be paired with the value of the checked item.

If more than one is checked, each name/value pair would be submitted to the server and it would be up to the server code to make sense of the response.