Archive for the ‘Prototype’ Category

toggle checkboxes listed in groups

Sunday, March 8th, 2009

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:

  1. [x] Category 1
    1. [x] product 1
    2. [x] product 2
    3. [x] product 3
  2. [ ] Category 2
    1. [ ] product 1
    2. [ ] product 2
    3. [ ] product 3

(more…)