How is name used for grouping?

In this section we use the name attribute for multiple inputs. In the lectue it says, that this would be used to group the values together. How would that look like on the receiving end?

We are using same name value TOPPING . for example, what if i need checkboxes to select bun’s size or bun’s materials? Can i use the NAME ATTRIBUTE with DIFFERENT VALUES in the same section or create a different section? i am asking because checker threw me error when i compiled with spelling mistake in NAME VALUE.

Radio buttons that are grouped all have the same name since we can only pick one. Check boxes, even when grouped still get their own individual names since we can select one, all, or none.

Spread to use
<input type="radio" name="spread">Butter
<input type="radio" name="spread">Margarine
<input type="radio" name="spread">Oleo
7 Likes

Nice topic
Using the same name for each checkbox groups the <input> s together.
What does it mean?
I even tried puting different names for each input’s name, like topping1, topping2 and topping3, but didn’t see any difference on the screen.

If you see anywhere that I state checkboxes cannot have the same name, tag me in so I can correct that. They can be grouped, but there are provisos.

https://www.dyn-web.com/tutorials/forms/checkbox/same-name-group.php

Note the use of FIELDSET to indicate grouping. More importantly, the use of [] to indicate an array of choices.

2 Likes

i think you are going too fast, at this point, we are not at the ‘radio lesson’ yet, it’s the next exercise :wink:
Unless the questions section of the radio buttons will take us here too and i’m not aware of it yet. but you seem to do that often (giving answers based on exercises we are not at yet).
this is just something i noticed and is meant to be constructive, it’s not a blame or anything!

When there is no link to the exercise we are left guessing. It’s why we stress so much posting the link and code with one’s question.

2 Likes

my bad, i thought the question section was automaticaly linked to the exercise page. thank you for your quick reply :smiley:
we were here: https://www.codecademy.com/courses/learn-html/lessons/html-forms/exercises/checkbox-input

2 Likes