I have this markup from a cakephp generated ctp file.
This Is basically a checkbox group with hobbies.
So, I want to check all/uncheck all using jquery and after all have been checked if I uncheck a single box ,check all will be removed and so if I check all individual check boxes check all box will be automatically checked.
My code:
<div class="checkgroup">
<input type="checkbox" name="data[Student][hobby][]" value="checkAll" id="StudentHobbyCheckAll" />
<label for="StudentHobbyCheckAll">Check All/Uncheck All</label>
</div>
<div class="checkgroup">
<input type="checkbox" name="data[Student][hobby][]" value="sports" id="StudentHobbySports" />
<label for="StudentHobbySports">Sports</label>
</div>
<div class="checkgroup">
<input type="checkbox" name="data[Student][hobby][]" value="movies" id="StudentHobbyMovies" />
<label for="StudentHobbyMovies">Movies</label>
</div>
<div class="checkgroup">
<input type="checkbox" name="data[Student][hobby][]" value="netsurfing" id="StudentHobbyNetsurfing" />
<label for="StudentHobbyNetsurfing">Netsurfing</label>
</div>
<div class="checkgroup">
<input type="checkbox" name="data[Student][hobby][]" value="photography" id="StudentHobbyPhotography" />
<label for="StudentHobbyPhotography">Photography</label>
</div>