How to allow only one radio button to be checked?

HtmlDjangoForms

Html Problem Overview


{% for each in AnswerQuery %}
    <form action={{address}}>
        <span>{{each.answer}}</span><input type='radio'>
        <span>Votes:{{each.answercount}}</span>
        <br>
    </form>
{% endfor %}

This is a part my django template, what it supposed to do is to print out several radio buttons, corresponding to the answers assigned to the buttons. But I don't know why I can check multiple radio buttons, which messed me up. It is supposed to only let me check on one radio button and I had that somehow but I lost it. Any help? Thank you.

Html Solutions


Solution 1 - Html

Simply give them the same name:

<input type="radio" name="radAnswer" />

Solution 2 - Html

They need to all have the same name.

Solution 3 - Html

All radio buttons have to have the same name:

<input type='radio' name='foo'>

Only 1 radio button of each group of buttons with the same name can be checked.

Solution 4 - Html

Give them the same name, and it will work. By definition Radio buttons will only have one choice, while check boxes can have many.

<input type="radio" name="Radio1" />

Solution 5 - Html

Add "name" attribute and keep the name same for all the radio buttons in a form.

i.e.,

<input type="radio" name="test" value="value1"> Value 1
<input type="radio" name="test" value="value2"> Value 2
<input type="radio" name="test" value="value3"> Value 3

Hope that would help.

Solution 6 - Html

Just give them the same name throughout the form you are using.

<form><input type="radio" name="selection">
      <input type="radio" name="selection">
      ..
      ..
</form>

Solution 7 - Html

All the radio buttons options must have the same name for you to be able to select one option at a time.

Solution 8 - Html

Only one Step you need to follow!

> Make Sure you need to add the attribute name in the opening tag with the same values of that attribute name! > > Example :

<input name="18+" value="yes" id="18" type="radio">Yes
  <input name="18+" value="No" id="bel" type="radio">No

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionClinteney HuiView Question on Stackoverflow
Solution 1 - HtmlShadow Wizard Says No More WarView Answer on Stackoverflow
Solution 2 - HtmlDouglasView Answer on Stackoverflow
Solution 3 - HtmlNickView Answer on Stackoverflow
Solution 4 - HtmlFluxEngineView Answer on Stackoverflow
Solution 5 - HtmlSuKuView Answer on Stackoverflow
Solution 6 - HtmlVinayKumar.MView Answer on Stackoverflow
Solution 7 - HtmlB.KView Answer on Stackoverflow
Solution 8 - HtmlPavan TanniruView Answer on Stackoverflow