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 HTML Forms Choosing Options Radio Buttons

James Barrett
James Barrett
13,253 Points

What is the value attribute doing for the radio buttons?

I am unclear on what 'value' is actually doing to the buttons. I changed both values to random letters to see if anything would change and nothing happened. What is 'under_13' and 'over_13' doing?

Thanks! James.

2 Answers

rydavim
rydavim
18,814 Points

From the w3schools page:

For radio buttons, the contents of the value property do not appear in the user interface. The value property only has meaning when submitting a form.

The value property on a radio button is used server-side to determine which button was selected. It's important to set different values for radio buttons in the same group for server-side implementation - but you won't actually display or use this information in your HTML. Consider that you might also use this value in your CSS as a selector, if you wanted to add a special style for a particular button.

Hopefully that helps clear things up. Happy coding! :)

James Barrett
James Barrett
13,253 Points

Thanks for your response! So for now I shouldn't really worry too much about what it is doing. Only that it is an attribute to be used in a server-side language

Value - For "checkbox", "radio", "image" - it defines the value associated with the input (this is also the value that is sent on submit)

I believe it ties in with actually 'submitting' information, which will be covered later.