Search code examples
javascriptcheckboxinputradio-buttonmustache

Multiple radio input checked


My problem seems quite simple but i can't see what's going wrong. I am just trying to have a simple multiple-choice form with only one choice possible, with the help of radio inputs.

I am using a loop with Mustache.js and I believe it prevents it from working, because I can select every input at the same time

Here's the code

<ul class="list-group mongroupe">{{#liens}}<form>
<li class="list-group-item"><div  onclick="sessionStorage['idpatient']='{{patient}}'">
<input type="radio" name="listemp" value={{patient}}/><h2> {{patient}} </h2> </div>
</li></form>
{{/liens}}
</ul>

Even though the inputs have the same name (others questions take this for a solution). I'd thankful for a hint on how to solve this.


Solution

  • Move the form outside the ul or at least outside the #liens block. Your rendered HTML probably has one form for each radio button which means each radio is alone in it's own group.