function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Stefano AmentaStefano Amenta 

Auto Hiding HTML elements in Visualforce

Hi,
I have built a Visualforce page with Apex and html, it's linked to a button in the Visa__c object record and this button prints a contract as pdf.

I have a condition that if Opportunity_Region__c = Chengdu, then the <th> tag should not be rendered in the page.

I used this code doesn't work, although in the record I can see Opportunity_Region__c = Chengdu

Do you know what is missing?

Thanks,

 
<br><tr>
                <th style="width:50%; display:{!IF(Visa__c.Opportunity_Region__c = 'Chengdu', 'block','none')}">6. Social Insurance</th>
                <th style="width:50%; padding-left: 20px; display:{!IF(Visa__c.Opportunity_Region__c = 'Chengdu', 'block','none')}">6. 社会保险</th>
            </tr></br>

 
SandhyaSandhya (Salesforce Developers) 
Hi,

Try using below which worked for me.
<th style="{!IF((Visa__c.Opportunity_Region__c = 'Chengdu', 'display:block', 'display:none')}" >6. Social Insurance</th>

Please mark it as solved if my reply was helpful, it will make it available
for others as a proper solution.

Best Regards,
​Sandhya
 
Stefano AmentaStefano Amenta
Hi Sandhya,

I tried your code but doesn't work for me.

The text is still rendered on the page.
 
<br><tr>
                <th style="width:50%; {!IF(Visa__c.Opportunity_Region__c = 'Chengdu', 'display:block','display:none')}">6. Social Insurance</th>
                <th style="width:50%; padding-left: 20px;">6. 社会保险</th>
            </tr></br>
User-added image

This is the rendered page:

User-added image