0

I want to disable the pageblock section when the checkbox is checked,enable it when the check box is unchecked. I had tried with rerender but it is not working as expected.

Note:The checkbox is placed inside another pageblock

<apex:pageBlock>
   <apex:outputLabel >Payment accepted</apex:outputLabel>

   <apex:inputCheckbox value="{!testCheck }">
      <apex:actionSupport event="onchange" action="{!updateTestCheck}" reRender="casePB" status="statusSaveTrip" />
   </apex:inputCheckbox>
</apex:pageBlock>

<apex:pageBlock id="casePB">
   <apex:outputpanel>
      <apex:outputLabel >Customer Wants:</apex:outputLabel>

      <apex:selectList value="{!Customerselectedid}"  multiselect="false" size="1" >
         <apex:selectOptions value="{!customerwantoptions}"></apex:selectOptions>
         <apex:actionSupport event="onchange" reRender="casePB" action="{!enableCCButton}" status="statusSaveTrip"/>
      </apex:selectlist>

      <apex:commandButton styleClass="btn btn-primary btn-xs"  value="Create Case"  action="{!logACase}" disabled="{!isCaseButton}" status="statusSaveTrip"/>
   </apex:outputpanel>
</apex:pageBlock>
4
  • Even instead of disable/enable we can hide/show pageblock also. Any pointers on this? Feb 3, 2017 at 6:11
  • Are you changing the value of isCaseButton in your updateTestCheck method? Feb 3, 2017 at 6:26
  • Yes @CasparHarmer , i am updating the disabled property of command button only when the checkbox is unchecked. The updtaeTestCheck() is going to execute only when the checkbox is unchecked Feb 3, 2017 at 6:37
  • Can you please check my answer and close this question Feb 5, 2017 at 19:39

1 Answer 1

1

I hope that you are changing checkbox values in the controller method.

You can wrap pageblock into an outputPanel and rerender the outputPanel from actionSupport call.

Display the pageblock based on checkbox is checked.

Below is the code:

<apex:pageBlock>
   <apex:outputLabel >Payment accepted</apex:outputLabel>

   <apex:inputCheckbox value="{!testCheck }">
      <apex:actionSupport event="onchange" action="{!updateTestCheck}" reRender="panel1" status="statusSaveTrip" />
   </apex:inputCheckbox>
</apex:pageBlock>

<apex:outputpanel id="panel1" >
<apex:pageBlock id="casePB" rendered={!testCheck}>   
      <apex:outputLabel >Customer Wants:</apex:outputLabel>

      <apex:selectList value="{!Customerselectedid}"  multiselect="false" size="1" >
         <apex:selectOptions value="{!customerwantoptions}"></apex:selectOptions>
         <apex:actionSupport event="onchange" reRender="casePB" action="{!enableCCButton}" status="statusSaveTrip"/>
      </apex:selectlist>

      <apex:commandButton styleClass="btn btn-primary btn-xs"  value="Create Case"  action="{!logACase}" disabled="{!isCaseButton}" status="statusSaveTrip"/>

</apex:pageBlock>
</apex:outputpanel>

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .