Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Apr 2005
    Posts
    45
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Got Code, but need to reverse effects.

    Currently this code (I got from another site) will disable any number of checkboxes when you click a 'master' checkbox.

    But what I want it to do is to make the master checkbox ENABLE the other checkboxes.

    Code:
    <script language="JavaScript" type="text/javascript">
    
    // The check box group is definded by the check boxes with a parent of the same title
    // A check box with a parent node of the group title suffixed with 'f7_Master'
    // is used to set the disable status of the other check boxes
    // Example HTML Code for one group
    // <span title="Group1" >
    // <input title="Group 1 A" type="checkbox" name="" checked=true ><br>
    // <input title="Group 1 B" type="checkbox" name=""><br>
    // <input title="Group 1 C" type="checkbox" name=""><br>
    // </span>
    
    // <span title="Group1f7_Master" >
    // <input title="Group 1 Master" type="checkbox" name=""><span id="fredTxt" >Master</span><br>
    // </span>
    
    // or to force the disabled group into a checked state of checked use
    // <span title="Group1f7_MasterCHECK" >
    // <input title="Group 1 Master" type="checkbox" name=""><span id="fredTxt" >Master</span><br>
    // </span>
    
    // or to force the disabled group into a checked state of unchecked use
    // <span title="Group1f7_MasterUNCHECK" >
    // <input title="Group 1 Master" type="checkbox" name=""><span id="fredTxt" >Master</span><br>
    // </span>
    
    
    
    // Each group is initialised from a <body> onload event
    // <body onload="f7_DisableCBGroup();" >
    // where
    
    // All variable, function etc. names are prefixed with 'f7_' to minimise conflicts with other javascripts
    
    
    var f7_cks;
    
    function f7_DisableCBGroup(){
     f7_cks=document.getElementsByTagName('INPUT');
     for (f7_0=0;f7_0<f7_cks.length;f7_0++){
      if (f7_cks[f7_0].type=='checkbox'){
       if (f7_cks[f7_0].parentNode.title.match('f7_Master')){
        f7_cks[f7_0].parentNode.state=f7_cks[f7_0].parentNode.title.split('f7_Master')[1];
        f7_cks[f7_0].parentNode.title=f7_cks[f7_0].parentNode.title.replace(f7_cks[f7_0].parentNode.state,'')
        f7_Disable(f7_cks[f7_0])
        f7_cks[f7_0].onclick=function(){ f7_Disable(this); }
       }
      }
     }
    }
    
    function f7_Disable(f7_obj){
     for (f7_1=0;f7_1<f7_cks.length;f7_1++){
      if (f7_cks[f7_1].parentNode.title==f7_obj.parentNode.title.replace('f7_Master','')){
       if (f7_obj.checked){
        f7_cks[f7_1].setAttribute('disabled',true)
        if (f7_obj.parentNode.state=='CHECK'){
         f7_cks[f7_1].checked=true;
        }
        if (f7_obj.parentNode.state=='UNCHECK'){
         f7_cks[f7_1].checked=false;
        }
       }
       else {
        f7_cks[f7_1].removeAttribute('disabled')
       }
      }
     }
    }
    
    
    //-->
    </script>
    Oh and mind you, I need the master checkbox to be a radio.
    Last edited by Icedan; 08-18-2005 at 05:47 AM.

  • #2
    New Coder
    Join Date
    Apr 2005
    Posts
    45
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Nevermind, I sorted the problem.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •