...

View Full Version : Got Code, but need to reverse effects.



Icedan
08-18-2005, 06:31 AM
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.



<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.

Icedan
08-18-2005, 10:51 AM
Nevermind, I sorted the problem. :thumbsup:



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum