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 created this now when I click on any parent with parentid = 0. All of its children should be automatically clicked with parentid> 0, but not vice versa. How can I do this in jquery? (HOW DO I CLICK ON SOME CHARACTERISTICS Manage your child's user. Add user, edit and delete user should be clicked automatically), but if I click on add user, nothing should happen.

+2


a source to share


1 answer


Not sure if you are referring to parentid, I will put a check for id> 0 if that's what you mean. You can simply change this condition to match the parent id.

EDIT: Set class "parentId" on checkboxes with parentId> 0 and do the following:



$("input:checkbox .parentId").live("click",function(){       
          $(this).children("input:checkbox").attr('checked', $(this).attr('checked'));         
});

      

+1


a source







All Articles