0

I am trying to display a textfield when 'Yes' checkbox is checked, but due to addition of lookup field value on VF page textfield is stopped displaying when I check the checkbox. That means only one textfield is showing either lookupfield or textfield when I check the checkbox. I need to show them both.

<apex:page standardController="Review__c" extensions="VFTestController" showHeader="false" standardStylesheets="false"> 
<apex:form >
<apex:pageBlock title=" Review">
<apex:pageblocksection >
           <apex:inputcheckbox value="{!chkBx}" label="Yes"> 
                <apex:actionSupport event="onchange" rerender="thePanel" action="{!click}"/>    
            </apex:inputcheckbox> 
           <apex:inputCheckbox label="No"/>  
</apex:pageblocksection><br></br>

If Yes..
<apex:pageblocksection >
 <apex:outputPanel id="thePanel">    
                <apex:pageBlockSectionItem rendered="{!displayInputputText}">
                    <apex:outputLabel value="Enter Text" />
                    <apex:inputText value="{!Review__c.X2Yes__c}"/>  
                </apex:pageBlockSectionItem>
            </apex:outputPanel>
</apex:pageblocksection>


Enter Contact Name:<br></br>
<apex:inputField value="{!Review__c.Contact__c}"/>
<br></br>
<div align="center" draggable="false" >
        <apex:commandButton action="{!save}" value="Submit"/>
</div><br></br>

</apex:pageBlock>
</apex:form>
</apex:page>

Controller Extentions:

 public Boolean displayInputputText{get;set;}
    public Boolean chkBx{get;set;}
    public String input{get;set;}       
    public PageReference click(){    
         if(chkBx){
             displayInputputText = true;
         }
         else{
             displayInputputText = false;
         }
         return null;
    }
1
  • What does the inputText field !Review__c.X2Yes__c do when you input text to it and click on Save? Does it change the value of the lookup? Knowing if there's a relationship between the two might help explain the behavior that you're seeing.
    – crmprogdev
    Dec 17, 2016 at 14:11

1 Answer 1

0

You have kept the rendered attribute to a pageblocksectionitem so only that field is enabled on Check equals true.

Move that boolean to pageblocksection instead to enable both fields

<apex:pageblocksection rendered="{!displayInputputText}">
   <apex:outputPanel id="thePanel">    
      <apex:pageBlockSectionItem>
         <apex:outputLabel value="Enter Text" />
         <apex:inputText value="{!Review__c.X2Yes__c}"/>  
     </apex:pageBlockSectionItem>

     <apex:pageBlockSectionItem>
        <apex:outputLabel value="Enter Contact Name:" />
        <apex:inputText value="{!Review__c.Contact__c}"/>  
     </apex:pageBlockSectionItem>
   </apex:outputPanel>
</apex:pageblocksection>


6
  • Still not working, I want to display Lookup inputtext field constantly and other inupttext field when I check the 'yes' checkbbox.
    – SFLearner
    Dec 8, 2016 at 7:28
  • If I remove the "Enter Contact Name:<br></br> <apex:inputField value="{!Review__c.Contact__c}"/> " then inputtext field is displaying. I want them both.
    – SFLearner
    Dec 8, 2016 at 7:29
  • So if you want only the inputtext field on change, then add the rendered attribute in that pageblocksectionitem tag instead of pageblocksection. Dec 8, 2016 at 8:03
  • I have done it already but not working.
    – SFLearner
    Dec 8, 2016 at 8:15
  • Try removing apex:outputPanel and add the id to pageblocksection and try to rerender the pageblocksection Dec 8, 2016 at 9:45

You must log in to answer this question.

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