Sometimes, we want to add multiple radio button groups in one form with HTML.
In this article, we’ll look at how to add multiple radio button groups in one form with HTML.
How to add multiple radio button groups in one form with HTML?
To add multiple radio button groups in one form with HTML, we ste the radio button’s name attribute to the same value.
For instance, we write
<form>
<fieldset id="group1">
<input type="radio" value="value1" name="group1" />
<input type="radio" value="value2" name="group1" />
</fieldset>
<fieldset id="group2">
<input type="radio" value="value1" name="group2" />
<input type="radio" value="value2" name="group2" />
<input type="radio" value="value3" name="group2" />
</fieldset>
</form>
to set the name
attribute to the radio buttons to the same value so we can select any one of them in the group.
Conclusion
To add multiple radio button groups in one form with HTML, we ste the radio button’s name attribute to the same value.