Hi Mohit,
You can do this by putting all the related fields or a single related field in an output panel.And on change on check box value just rerender your panel.
Panel will be rendered according to the value of check box
Here’s a sample code for this:
<apex:page controller=”CheckboxRerenderController”>
<apex:form >
<apex:pageBlock >
<apex:pageblocksection >
<apex:inputcheckbox value=”{!chkBx}” label=”checkBox”>
<apex:actionSupport event=”onchange” rerender=”thePanel” action=”{!click}”/>
</apex:inputcheckbox>
<apex:outputPanel id=”thePanel”>
/* Contains all the fields you want to show on checkbox value*/
<apex:pageBlockSectionItem rendered=”{!displayInputputText}”>
<apex:outputLabel value=”Input Text” />
<apex:inputText value=”{!input}”/>
</apex:pageBlockSectionItem>
</apex:outputPanel>
</apex:pageblocksection>
</apex:pageBlock>
</apex:form>
</apex:page>
Controller code:
public with sharing class CheckboxRerenderController {
public Boolean displayInputputText{get;set;}
public Boolean chkBx{get;set;}
public String input{get;set;}
public void click(){
if(chkBx){
displayInputputText = true;
}
else{
displayInputputText = false;
}
}
}