Click here to Skip to main content
15,885,757 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
JavaScript
function CheckUncheckParents(srcChild, check) {
  var parentDiv = GetParentByTagName("div", srcChild);
  var parentNodeTable = parentDiv.previousSibling;
            
  if (parentNodeTable) {
    if (parentNodeTable.attachEvent && parentNodeTable.fireEvent) {
      if (!parentNodeTable.addEventListener && parentNodeTable.attachEvent && parentNodeTable.fireEvent) {
        parentNodeTable.attachEvent("onclick", function click() {
          var checkUncheckSwitch = check;
          var inpElemsInParentTable = parentNodeTable.getElementsByTagName("input");

          if (inpElemsInParentTable.length > 0) {
            var parentNodeChkBox = inpElemsInParentTable[0];
            
            if (checkUncheckSwitch) {
              parentNodeChkBox.checked = checkUncheckSwitch;
            }
                                    
            //do the same recursively
            CheckUncheckParents(parentNodeChkBox, checkUncheckSwitch);
          }
        });
      }
    }
  }
}
Posted
Updated 18-Mar-15 0:59am
v2
Comments
ZurdoDev 18-Mar-15 8:21am    
What exactly is the problem?
siva Prasad Paruchuri 18-Mar-15 8:37am    
In IE 7 and 8. parent check box is not working, i.e once we select the parent check box it is not unselecting when we cick another time.
ZurdoDev 18-Mar-15 8:45am    
You may have to use the developer tools in IE8 to debug it then. You're likely using something in JS that IE7 and 8 don't support.
siva Prasad Paruchuri 18-Mar-15 8:38am    
checkbox tick mark is not hiding

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900