function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
lakshmi25lakshmi25 

how to disable

 In this  below page if i  check the ch checkbox ch2,ch3 checkboxes  want to disable but  only ch2 checkbox disabled and if i  check the ch2 checkbox ch,ch1 checkboxes  want to disable but  only ch  checkbox disabled.how to disable ch1,ch3 checkboxes please correct this code.

 

 

 

 

<apex:page controller="checkbox1" >
<apex:form >

<script>
function confirmDisbaled(ifchecked, id1 ,id2,id3) {


document.getElementById(id1).disabled = ifchecked;
document.getElementById(id2).disabled = ifchecked;
document.getElementById(id3).disabled = ifchecked;

}
</script>
<apex:pageBlock title="student details" id="pb" >
<apex:actionRegion >
<apex:pageBlockTable value="{!items}" var="s">
    <apex:column value="{!s.Name}"/>
 
    <apex:column >
    <apex:facet name="header">
    <apex:inputCheckbox onclick="checkAll1(this)" id="ch"  onchange="return confirmDisbaled(this.checked, '{!$Component.ch2}','{!$Component.ch3}');">
    <apex:actionSupport event="onclick" reRender="ch,ch1"/></apex:inputCheckbox>
    </apex:facet>
    
    <apex:inputCheckbox value="{!s.present__c}" id="ch1"  >
    </apex:inputCheckbox>
    </apex:column>
   <!-- onclick="if (this.checked) document.getElementById('ch3').disabled=true; else document.getElementById('ch3').disabled = false;"-->
    <apex:column >
    <apex:facet name="header">
    <apex:inputCheckbox onclick="checkAll2(this)" id="ch2"  onchange="return confirmDisbaled(this.checked, '{!$Component.ch}','{!$Component.ch1}');" >
   <apex:actionSupport event="onclick" reRender="ch2,ch3" /></apex:inputCheckbox>
    </apex:facet>
    
    <apex:inputCheckbox value="{!s.absent__c}" id="ch3"  >
   </apex:inputCheckbox>
    </apex:column>
    
    
</apex:pageBlockTable>
</apex:actionRegion>
</apex:pageBlock>
</apex:form>
<script>
        function checkAll1(cb)
        {
            var inputElem = document.getElementsByTagName("input");
            for(var i=0; i<inputElem.length; i++)
            {
                if(inputElem[i].id.indexOf("ch1")!=-1)
                {
                inputElem[i].checked = cb.checked;
                
                
                }
                 
            }
        }    
    </script>
    <script>
        function checkAll2(cb)
        {
            var inputElem = document.getElementsByTagName("input");
            for(var i=0; i<inputElem.length; i++)
            {
                if(inputElem[i].id.indexOf("ch3")!=-1)
                inputElem[i].checked = cb.checked;
                 
                 
            }
        }    
    </script>
    
</apex:page>

yvk431yvk431

try this

 

<apex:pageBlock id="theBlock">
   <apex:inputCheckbox value="{!theSObject.CheckBox__c}">
      <apex:actionSupport event="onchange" rerender="theBlock"/>
   </apex:inputCheckbox>

   <apex:inputCheckbox value="{!theSObject.TextField__c}" disabled="{!(theSObject.CheckBox__c == true)}"/>
   

   <!-- Or to simply have a field that appears only when the box is checked -->
   <apex:inputCheckbox value="{!theSObject.TextField__c}" disabled="{!(theSObject.CheckBox__c == true)}"/>
</apex:pageBlock>