Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
liam johnshon
Courses Plus Student 904 Pointshow to select one checkbox at same time ?
hey i faced a problem in checkbox selection i want to select one checkbox in same time
<div class="choices">
<input type = "checkbox" id="A" name="answer" class="choice0" value=""><label id="choice0" for="A">option1</label><br/>
<input type = "checkbox" id="B" name="answer" class="choice1" value=""><label id="choice1" for="B">option2</label><br/>
<input type = "checkbox" id="C" name="answer" class="choice2" value=""><label id="choice2" for="C">option3</label><br/>
<input type = "checkbox" id="D" name="answer" class="choice3" value=""><label id="choice3" for="D">option4</label><br/>
</div>

liam johnshon
Courses Plus Student 904 Pointsas a choice for questions of quiz

Brent Suggs
Front End Web Development Techdegree Graduate 21,343 Pointssorry, I think you misunderstood. Why are you wanting to select only one of them? For styling..? or are you trying to do the sytle for when one is checked/selected?
2 Answers

Jake Lundberg
13,965 PointsAre you required to use checkboxes? If not, you should use radio buttons instead. This would allow you to group buttons together, but only allow for one to be selected at a time.

Steven Parker
224,872 PointsI agree with using the radio buttons. Unless...
You may just WANT checkboxes, in which case you could give them behavior similar to radio buttons using a little JavaScript.
Your quiz might also have some questions where there might be more than one correct answer, and all of them should be selected.
Brent Suggs
Front End Web Development Techdegree Graduate 21,343 PointsBrent Suggs
Front End Web Development Techdegree Graduate 21,343 PointsWhat are you selecting them for? Just from this I'd say you'd have to use the 'id' to select them individually...