Form fields: Radio buttons

Radio buttons are similar to checkboxes, but only one radio button can be active.

Selecting one deselects the other ones.

By setting one as checked, you make sure one is always selected.

<input type="radio" name="category" value="article" checked />
<input type="radio" name="category" value="tutorial" />
<input type="radio" name="category" value="news" />

Since only one is active at a time, in the POST request you’ll use the get() method of the FormData instance to retrieve the value selected..

Lessons in this unit:

0: Introduction
1: Form submit field
2: Specialized input fields
3: Checkboxes
4: ▶︎ Radio buttons
5: File input fields
6: Textarea
7: Select
8: Autocompleting form fields
Are you intimidated by Git? Can’t figure out merge vs rebase? Are you afraid of screwing up something any time you have to do something in Git? Do you rely on ChatGPT or random people’s answer on StackOverflow to fix your problems? Your coworkers are tired of explaining Git to you all the time? Git is something we all need to use, but few of us really master it. I created this course to improve your Git (and GitHub) knowledge at a radical level. Launching May 21, 2024. Join the waiting list!