Given the following markup:
<form> <div class="project"> <ul class="choice"> <li><label for="firstchoice_1">First choice</label><input type="radio" name="firstchoice" value="1" id="firstchoice_1" /></li> <li><label for="secondchoice_1">Second choice</label><input type="radio" name="secondchoice" value="1" id="secondchoice_1" /></li> </ul> </div> <div class="project"> <ul class="choice"> <li><label for="firstchoice_2">First choice</label><input type="radio" name="firstchoice" value="2" id="firstchoice_2" /></li> <li><label for="secondchoice_2">Second choice</label><input type="radio" name="secondchoice" value="2" id="secondchoice_2" /></li> </ul> </div> </form>
What I want to do is turn it off if there is a switch in each .project group whenever a different one has been selected (therefore, you can only select First choice or Second choice in each group). I know how to do this - to disable one specific switch in one specific case, but I do not know how to generalize it, since they can be hundreds of such .project groups.
Change Please note that only the entire First choice (and vice versa) can be selected. The same name is already used for this. The same name attribute is used throughout the markup. There are only two different name s.
source share