The easiest way I can see of doing it is:

<div id="container">
  <div>
    <input type="checkbox" value="1"/>
    <div>
      <input type="checkbox" value="1.1">
      <input type="checkbox" value="1.2">
      <div>
        <input type="checkbox" value="1.3">
      </div>
      <input type="checkbox" value="1.3">
    </div>
  </div>
</div>

$('#container :checkbox').change(function(){
  var jQ = $(this), nest = jQ.next('div');
  if (jQ.attr('checked') == 'checked') // Checked - Check and disable
all children.
    nest.find(':checkbox').attr({checked: 'checked', disabled:
'disabled'});
  else // Unchecked - Uncheck and enable all children
    nest.find(':checkbox').attr({checked: '', disabled: 'disabled'});
});

It's untested, but I think it should work, and/or at least give you a
starting point for a way to achieve your goal.

On Jan 12, 11:54 am, bmclaughlin <i...@bmclaughlindesigns.com> wrote:
> I am hoping that someone has done this before.
>
> I am after something like this:http://static.geewax.org/checktree/index.html
> I will explain why this fine example does not work for my instance
> below.
>
> The behavior of the “United States” section in particular is what we
> are after.
> If a parent checkbox is checked, everything below that parent also
> gets checked.
> Unlike the example, there would not be a way to uncheck a child if the
> parent is selected.
>
> There are multiple “levels” of the parent child relationship.
> The example of the United States shown above has 2 levels.
> In our case there can be up to 9 levels of depth.
> In this case if the ultimate parent is selected, all 9 levels (all
> parent and all children) would be selected.
> When any parent within the hierarchy is selected, their children
> become selected.
>
> The system needs to work with checkboxes rather than images as shown
> in the example.
> This would mean that the checkboxes for the children of a selected
> parent are “disabled” thus not allowing a child to not be selected.
>
> We are currently using the tree from “sample 3” from Bassistance
> (http://jquery.bassistance.de/treeview/demo/) to get that behavior.
>
> If all this were not enough, the tree could contain 2,000 items that
> make up this hierarchy.
> So the less “building” the page has to do the better. All of the item
> will be loaded on the page when the page is rendered.

Reply via email to