I have just needed a toggling function made with javascript for checkboxes wich are grouped in lists. It should look like a hierarchical tree-like structure. When I check the box of my first tree-category, all related subcategories automatically must getting checked too.
I have used the prototype framework for other functionalities on the website, so I preferred to take use of it for helping me by developing this. Prototype framework comes with form functions like getInputs(), but this function gets completely all input fields of a form and not from a specified list, so this did not help me in this situation.
This is a silhouetted visualization of my grouped checkboxes:
- [x] Category 1
- [x] product 1
- [x] product 2
- [x] product 3
- [ ] Category 2
- [ ] product 1
- [ ] product 2
- [ ] product 3