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
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.
i think you are going too fast, at this point, we are not at the āradio lessonā yet, itās the next exercise
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.
my bad, i thought the question section was automaticaly linked to the exercise page. thank you for your quick reply
we were here: https://www.codecademy.com/courses/learn-html/lessons/html-forms/exercises/checkbox-input
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
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.
Thanks! I was curious about that
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.
In this case, my question is do we need to define āspreadā somewhere first in our code? because when it is shown in the screen, spread does not appear at all. so I thought it is kind arbitary by just naming it or in our tutorial, i think they name it ātoppingā but how did the server recognize such name?
Short answer, no. It does not need to display, but the label does stateā¦
Spread to use
In the above form, name="spread"
identifies the key name to assign to the value in the Submited form data associative array. Radio buttons cannot be selected in multiple so only one of the values will apply.
[ spread => Butter ]
https://localhost/?patty=&amount=&doneness=3&topping=lettuce&topping=tomato&topping=onion
This results in an array of selections as the value of topping
.
Try the example under āMultiple choicesā. Check all the boxes and submit to see the result.
Will giving multiple inputs the same ānameā help in the css file to style them as a group rather than individually?