Create a Set of Checkboxes for different questions but it wont stay checked when i check other question(codepen)

Create a Set of Checkboxes for different questions but it wont stay checked when i check other question(codepen)
0

#1

i created 2 questions. each has 2 checkboxes,. I can check the first one just fine. but when i check the second button on the second question, the first button becomes unchecked… how do i fix this. below is my link to codepen where i am working on it. thank you

https://codepen.io/3nduser/full/aVgqxg/


#2

Because all the radio buttons have the same name, it is like you have four options for the same question. Make the name different for the second set radio buttons.

Your topic says checkboxes, but these are actually radio buttons.


#3

ok. i fixed it. thank your for your help. but is there anyway to still use YES-NO on multiple radio buttons? or is that out of the question?


#4

Absolutely. See the following code. You just have to change the name attribute of the input. The label can be Yes/No for as many as you want.

    <p>Do you love animals?</p>
    <label><input type="radio" name="question1">Yes</label>
    <label><input type="radio" name="question1">No</label>
    <p>Do you care about your health?</p>
    <label><input type="radio" name="question2">Yes</label>
    <label><input type="radio" name="question2">No</label>

#5

Thank you!! It worked!!