DubFriend / jquery.repeater

Create a repeatable group of input elements
MIT License
391 stars 192 forks source link

Radio buttons group not working #80

Open KeppensJonas opened 6 years ago

KeppensJonas commented 6 years ago

I have this in my code:

when I add more items with the form repeater I can always select all the radio buttons while there is a group name. What's the problem here?

rehrman commented 6 years ago

First post, so be gentle if I am doing it incorrectly. :)

I ran into this problem and handled it by grouping all the checkboxes with a class name, and had each call a little "uncheck all" / "check current" method when clicked. I used checkboxes, but it should work just as well with radio buttons.

HTML <input type="checkbox" id="CtrlName" name="CtrlName" class="group-name" onclick="markCheckBox(this.attributes['name'].value);" value="" />

JavaScript function markCheckBox(ctrl) {$('input:checkbox.group-name').prop("checked", false); $("[name='" + ctrl + "']").prop("checked", true); }