+ Start a Discussion
lil_rangerlil_ranger 

display section if checkbox is false

I am rendering a VF page as a word doc and I ran into 1 issue that I can't seem to fix.  I'd like this section to only appear if the "Training Site Address" checkbox is not checked, but it's displaying it when it is checked. Any help would be greatly appreciated.

 

<div style = "{!IF(Contract.Training_Site_Address__c == false,'','display:none;')}"> 
<table border="1" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td><b>Company:</b> {!Contract.Training_Site_Company__c}</td>
<td></td>
</tr>
<tr>
<td><b>Attn:</b> {!Contract.Training_Site_POC__c}</td>
<td></td>
</tr>
<tr>
<td><b>Address:</b> {!Contract.Training_Site_Street_Address__c}</td>
<td></td>
</tr>
<tr>
<td width="75%"><b>City:</b> {!Contract.Training_Site_City__c}</td>
<td width="75%"><b>State:</b> {!Contract.Training_Site_State__c}</td>
</tr>
<tr>
<td width="75%"><b>Zip/Postal Code:</b> {!ROUND(Contract.Training_Site_Zip_Code__c,0)}</td>
<td width="75%"><b>Country:</b> {!Contract.Training_Site_Country__c}</td>
</tr>
</table>
</div>

 

Best Answer chosen by Admin (Salesforce Developers) 
lil_rangerlil_ranger

The output panel did the trick.  Here is my final code if anyone needs it.

 

<apex:outputPanel rendered="{!IF(Contract.Training_Site_Address__c== false,'','display:none;')}">

<table border="1" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td><b>Company:</b> {!Contract.Training_Site_Company__c}</td>
<td></td>
</tr>
<tr>
<td><b>Attn:</b> {!Contract.Training_Site_POC__c}</td>
<td></td>
</tr>
<tr>
<td><b>Address:</b> {!Contract.Training_Site_Street_Address__c}</td>
<td></td>
</tr>
<tr>
<td width="75%"><b>City:</b> {!Contract.Training_Site_City__c}</td>
<td width="75%"><b>State:</b> {!Contract.Training_Site_State__c}</td>
</tr>
<tr>
<td width="75%"><b>Zip/Postal Code:</b> {!ROUND(Contract.Training_Site_Zip_Code__c,0)}</td>
<td width="75%"><b>Country:</b> {!Contract.Training_Site_Country__c}</td>
</tr>
</table>
</apex:outputPanel> 

 

All Answers

asish1989asish1989

Hi 

   make sure that your checkbox field is unchecked bu default.

  then add this line 

    <div style = "{!IF(Contract.Training_Site_Address__c ==true,'display:none;','')}">

 

 

 

did this post answers your questions if yes please mark it as solutions.

 

thanks

asish

lil_rangerlil_ranger

Hi,

 

I tried your suggestion, but it's still showing that section when the checkbox is checked.  What I find strange is I have other div statements in my page and they work fine.  

 

Thanks,

Lisa

 

asish1989asish1989

Hi Lisa

    why dont you use outputpanel instead of div. I am giving an idea you may refer

 //div which you want to   hide when check box is checked 

<apex:OutputPanel id="panel">

          <apex:OutputPanel rendred="{!visible =='hi'}">

                   // your information.....

          </apex:OutputPanel>

           Training_Site_Address__:<apex:inputcheckbox value="{!selected}" >
                                  <apex:actionSupport event="onclick" action="{!getSelected}" rerender="panel"/>
             </apex:inputcheckbox>

</apex:OutputPanel>

 

Now controller ...

 

public class yourclass{

   public String visible{get;set;}

   public Boolean selected{get;set;}

 

         public yourclass() {

             visible = 'hi';

              //your code..

         }

public PageReference getSelected(){

    if(selected== true){

      visible = null;

   }

   

}

 

Lisa , dont make that field Training_Site_Address__ for this purpose, If this field has other requirement then you may use.

 

Did this post answers your questions, if so please mark it as a solutions

 

Thanks

asish.

 

lil_rangerlil_ranger

The output panel did the trick.  Here is my final code if anyone needs it.

 

<apex:outputPanel rendered="{!IF(Contract.Training_Site_Address__c== false,'','display:none;')}">

<table border="1" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td><b>Company:</b> {!Contract.Training_Site_Company__c}</td>
<td></td>
</tr>
<tr>
<td><b>Attn:</b> {!Contract.Training_Site_POC__c}</td>
<td></td>
</tr>
<tr>
<td><b>Address:</b> {!Contract.Training_Site_Street_Address__c}</td>
<td></td>
</tr>
<tr>
<td width="75%"><b>City:</b> {!Contract.Training_Site_City__c}</td>
<td width="75%"><b>State:</b> {!Contract.Training_Site_State__c}</td>
</tr>
<tr>
<td width="75%"><b>Zip/Postal Code:</b> {!ROUND(Contract.Training_Site_Zip_Code__c,0)}</td>
<td width="75%"><b>Country:</b> {!Contract.Training_Site_Country__c}</td>
</tr>
</table>
</apex:outputPanel> 

 

This was selected as the best answer