+ Start a Discussion
Dylan ConleyDylan Conley 

Rerender inputField on inputCheckbox change not working

I'm trying to do something similar to what's been posted here and have literally copied the code without success. To summarize, I'm trying to rerender fields (or a pageBlockSection) when I check an inputCheckbox using apex:actionsupport. 

 

Here's the VF (taken from the referenced thread):

 

 <apex:pageBlockSection id="debugBlock" rendered="{!IF(test2 == true,true,false)}" >
         Checked
 </apex:pageBlockSection>
 <apex:inputCheckbox value="{!test2}">
        <apex:actionsupport event="onchange" rerender="debugBlock" />     
 </apex:inputCheckbox>

 

I've also tried with rendered="{!test2}" and had no luck.

 

Here's the controller code:

 

public boolean test2 {get; set;}

Pretty strange considering almost identical code worked in the previous thread. Any help is greatly appreciated. 

 

Thanks,

Dylan

Best Answer chosen by Admin (Salesforce Developers) 
jd123jd123

Hi Dylan Conley 

 

   try this code

 

<apex:outputpanel id="working">
<apex:pageBlockSection id="debugBlock" rendered="{!IF(test2 == true,true,false)}" > Checked </apex:pageBlockSection> <apex:inputCheckbox value="{!test2}"> <apex:actionsupport event="onchange" rerender="working" /> </apex:inputCheckbox>
<apex:outputpanel>

If this is the reply to post and answers your question then please mark it as solution.









All Answers

MJR_NexMJR_Nex

I have also had issues with rerender. Since you are using an inputCheckbox, I am assuming that this is nested within <Apex:Form> tags. Try rerendering the entire form, instead of this one element. I've found that to work in most cases.

jd123jd123

Hi Dylan Conley 

 

   try this code

 

<apex:outputpanel id="working">
<apex:pageBlockSection id="debugBlock" rendered="{!IF(test2 == true,true,false)}" > Checked </apex:pageBlockSection> <apex:inputCheckbox value="{!test2}"> <apex:actionsupport event="onchange" rerender="working" /> </apex:inputCheckbox>
<apex:outputpanel>

If this is the reply to post and answers your question then please mark it as solution.









This was selected as the best answer
Dylan ConleyDylan Conley

Thanks for the quick responses. JD, your solution worked! Posted below with a "/" on the closing outputPanel.

 

<apex:outputpanel id="working">
 <apex:pageBlockSection id="debugBlock" rendered="{!IF(test2 == true,true,false)}" >
         Checked
 </apex:pageBlockSection>
 <apex:inputCheckbox value="{!test2}">
        <apex:actionsupport event="onchange" rerender="working" />     
 </apex:inputCheckbox>
</apex:outputpanel>

Thanks!

Dylan

 

 

sheensheen

Hi ,

Solution work for me as well but  why do inputcheckbox need to  put within the outpanel to rerender it?

 

why is it not working for the checkbox outside?