HTML HTML Forms Choosing Options Radio Buttons

James Barrett
James Barrett
13,252 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
MOD
rydavim
Treehouse Moderator 16,630 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,252 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.