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.

1 Like

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!

1 Like

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.

4 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

4 Likes

Hi, thanks always for replying to the questions written in the board. Your replies have been most helpful.
Pretty much the syntax in the examples you have given is pretty self-explanatory. Otherwise, it is enough for anyone to go away and do their own individual research from the various sources available online.
I appreciate the help :slight_smile:

2 Likes

https://www.codecademy.com/courses/learn-html/lessons/html-forms/exercises/checkbox-input
Hello Roy,
I have a question regarding this exercise.
The section class=“toppings”. Shouldn’t the name= in each input be set to “toppings” as well? The exercise instructs to use “topping”, dropping the (s).
Thank you!

There is no real problem in the singular term being used. However, it would be nice if we could somehow examine the POSTDATA to see how it appears in the request header. The multiple values come into question in terms of how they get passed as a group. Will need to do some research on that.


Just now spotted the query string in the localhost location bar.

https://localhost/?patty=beef&amount=2&doneness=3&topping=lettuce&topping=tomato&topping=onion

Not sure how that will get resolved by the form handler.

1 Like

Thanks! I was curious about that :slight_smile:

1 Like

According to your query string name topping has been mentioned three times and all those have different values. if i am not wrong name is like a variable which holds the value of input. In this query string what is the actual value hold by topping. if all of three values are being stored simultaneously then how it works. I am finding it hard to understand what it will store value and how it will transfer this information to the server.

TBH, I don’t have a good answer. That query string is not my invention but copied from the location bar of the localhost browser in the LE.