Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple Radio Button Groups With Same Name

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.

like image 568
clamchoda Avatar asked Jun 11 '15 21:06

clamchoda


People also ask

How to use radio buttons with different names in forms?

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.

How to insert radio buttons in group boxes?

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.

Why can’t I select multiple radio buttons in Excel?

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?

What is a radio button in HTML?

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.


1 Answers

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>
like image 108
RJ.Hwang Avatar answered Sep 30 '22 18:09

RJ.Hwang