You need to sign in to do that
Don't have an account?
prazon
Help needed!!! showing and hiding a pageBlockSectionItem
I want to display and hide a pageblocksection item based on a inputChechbox checked or not. Is there any sample code ? Please help me on this.
Hi,
Try the below code snippet as reference:
<apex:page id="page" >
<apex:form id="frm">
<apex:inputCheckbox title="sdf" onchange="displaybb(this)" label="display" />
<apex:pageBlock id="ps" >
<apex:pageBlockSection title="dffg" id="pbsec" >
<apex:pageBlockSectionItem ><apex:outputLabel >heloo</apex:outputLabel> </apex:pageBlockSectionItem>
</Apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
<script>
function displaybb(val)
{
if(val.checked==true)
{
document.getElementById('page:frm:ps:pbsec').style.display='block';
}
else
{
document.getElementById('page:frm:ps:pbsec').style.display='none';
}
}
document.getElementById('page:frm:ps:pbsec').style.display='none';
</script>
</apex:page>
Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.
Hi Prazon, (or you can use following code)
Controller Class
------------------------
public class Sample {
public Boolean isChecked { get; set; }
}
Visualforce page
------------------------
<apex:page controller="Sample" >
<apex:form >
<apex:inputCheckbox id="SampleCheck" value="{!isChecked}" >
<apex:actionsupport event="onclick" rerender="SampleView" />
</apex:inputCheckbox>
<apex:outputPanel id="SampleView">
<apex:pageBlock id="SampleBlock" rendered="{!isChecked}" >
<apex:pageBlockSection >
<apex:pageblockSectionItem >
<apex:outputlabel value="Section 1"/>
</apex:pageblockSectionItem>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:outputPanel>
</apex:form>
</apex:page>
Thanks,
JBabu.