views:

51

answers:

1
+2  Q: 

checkboxes jquery

<% foreach (var i in (IEnumerable<MvcApplication1.Models.Group>)ViewData["Group"]) 
   { %> 
       <input type="checkbox" name="Inhoud" value="<%= i.int_GroupId %>"  /> <%= i.vcr_GroupName %><br /><br />(Checkboxes here)
       <% foreach (var ik in (IEnumerable<MvcApplication1.Models.Feature>)ViewData["Feature"])
          { %>
             <input type="checkbox" name="Inhoud" value="<%= ik.int_FeatureId  %>"  /> <%= ik.vcr_FeaturesName %><br />  (Checkboxes here) 
              <% } %> 
   <br /> 
<% } %> 

I have created this now the thing is that when I click on any parent with parentid=0 .all its child should automatically be clicked with parentid >0 but not viceversa.How would I do it in jquery? (Like i CLICK ON SOME FEATURE Manage User its child Add user ,edit and delete user should be clicked automatically ) but if i click on add user nothing should happened

+1  A: 

Not sure what your referring to by parentid, i put a check for the id > 0 if that's what you mean. You can just change that condition to match the parent id.

EDIT: set a class of "parentId" on checkboxes with a parentId > 0 and do the following:

$("input:checkbox .parentId").live("click",function(){       
          $(this).children("input:checkbox").attr('checked', $(this).attr('checked'));         
});
derek
PARENTID IS COMING FROM DATABASE
mazhar kaunain baig
ok, then you either don't need that condition at all, or you will need to set a class on the checkboxes and check for that class. See edit.
derek