Form Attributes Clarification

Hello,

Just finished the Survey Form Challenge and managed to fulfill all of the user stories. However, I was hoping for some clarification on the difference between and reasons for the following form attributes: name, ID, for and value. They seem to frequently carry the same value and I am having trouble understanding why they are all needed and why they aren’t redundant. Here’s my best understanding thus far:

Name: ??? no idea ???
ID: for styling purposes
For: to identify data returned to the coder
Value: ??? no idea ??? (Seems the user provides this when they provide the input.)

Could someone explain what these are for and why all 4 were needed in the form for this challenge? Are all four of these needed for every form?

Here is my project link: https://codepen.io/rjlamont/pen/KKaEqJN
(I am also not clear on the proper etiquette for questions. I see a lot of leader responses asking for code in between lines with 3 back ticks. Are back ticks back slashes and should I copy & paste the code instead of giving the link?)

Any responses and feedback are appreciated.

MDN has a nice form guide. I would suggest you go through it.

https://developer.mozilla.org/en-US/docs/Learn/Forms/Your_first_form

Thank you! I read the guide and it did clarify these attributes for me, so I really appreciate the link. For any other student that might find this thread helpful, I’d like to point out something specific that help my understanding. From my question, it’s clear that I didn’t at all understand the purposes of the name and value attributes. From the guide you shared, I learned that these attributes pair up to ease data management. From the article:

The names are important on both the client- and server-side; they tell the browser which name to give each piece of data and, on the server side, they let the server handle each piece of data by name. The form data is sent to the server as name/value pairs.

So, again, thank you for the response. It was immensely helpful. :slightly_smiling_face:

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.