Paulus62
Paulus62

Reputation: 11

How to select multiple radiobuttons on one page?

I want to build a questionnaire in HTML. Every question in the list can be answered by selecting one of four radiobuttons.

The problem I am facing is that I can only select one choice on the whole page, while I want to be able to select one choice per question.

When I have a list of questions and I have picked an alternative for question 1, I turn to question 2.

When I select an alternative for question 2, the chosen radiobutton for question 1 is deselected.

The radiobuttons for different questions have different names, the radiobuttons for 1 question have the same name. I included every question in a fieldset, but that does not work.

Does anyone know how to accomplish this? Any help will be greatly appreciated.

Upvotes: 1

Views: 93

Answers (1)

Oscar LT
Oscar LT

Reputation: 797

You have to group your radio buttons by name:

 <input type="radio" name="group1" value="one">One<br>
 <input type="radio" name="group1" value="two">Two<br>
 <input type="radio" name="group1" value="three">Three<br>
 <input type="radio" name="group1" value="four">Four<br><br>

 <input type="radio" name="group2" value="a">a<br>
 <input type="radio" name="group2" value="b">b<br>
 <input type="radio" name="group2" value="c">c<br>
 <input type="radio" name="group2" value="d">d<br>

https://jsfiddle.net/ajjbfj0v/2/

Upvotes: 1

Related Questions