I have been passed down a complex application which dynamically creates HTML.
The problem is, the previous person did not know that the "name" attribute of radio buttons actually is the group association.
With the following mark up, is there any way to put these in two groups
<div>
<%-- would like this to be a seperate group without changing name--%>
<label class="radio-inline"><input type="radio" name="radio" value="1">Group 1 Option 1</label>
<label class="radio-inline"><input type="radio" name="radio" value="2">Group 1 Option 2</label>
<label class="radio-inline"><input type="radio" name="radio" value="3">Group 1 Option 3</label>
</div>
<div>
<%-- would like this to be a seperate group without changing name--%>
<label class="radio-inline"><input type="radio" name="radio" value="1">Group 2 Option 1</label>
<label class="radio-inline"><input type="radio" name="radio" value="2">Group 2 Option 2</label>
<label class="radio-inline"><input type="radio" name="radio" value="3">Group 2 Option 3</label>
</div>
Is there any div or anything I can wrap around them to separate the grouping? I have tried field set and legend but it has no effect. I know I could put each one in a form but then they will not all be submitted.
It is a good practice to use a <label> tag along with radio buttons for better accessibility. We can define a group for radio buttons by giving each radio button the same name. As and when the user selects a particular option from this group, other options are deselected. Following is an example of radio buttons with different names within a form.
Then you can insert the option buttons into the group boxes, please click Developer > Insert > Option Button (Form Control) and draw some radio buttons into the group boxes, see screenshots: 5.
That’s because radio buttons are not designed to allow multiple selections. But if you want to insert multiple sets of option buttons and need to check one button from each group as following screenshots shown. How could you do in Excel?
HTML Radio Button – Radio Group and Attributes HTML Radio button is typically used to select a particular option from a group of related options. To define a radio button, we use the <input> element of HTML.
Put them in different form tag
<form>
<label class="radio-inline"><input type="radio" name="radio" value="1">Group 1 Option 1</label>
<label class="radio-inline"><input type="radio" name="radio" value="2">Group 1 Option 2</label>
<label class="radio-inline"><input type="radio" name="radio" value="3">Group 1 Option 3</label>
</form>
<form>
<label class="radio-inline"><input type="radio" name="radio" value="1">Group 2 Option 1</label>
<label class="radio-inline"><input type="radio" name="radio" value="2">Group 2 Option 2</label>
<label class="radio-inline"><input type="radio" name="radio" value="3">Group 2 Option 3</label>
</form>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With