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
SFDC_BeginerSFDC_Beginer 

Reg: Styles on VF page

Hi,

 

I have a list of records that are returning from class to vf of pageblocktable.

 

Now, in that list the field status__c contains the values pass or fail.

 

suppose if the status__c is "fail" then i would like to apply the color as "Red". If it is "pass" i would like to apply the color as "Green" to this value on VF page.

 

Can any one please give a statement for applying different colors using style class on vfpage?

 

 

Thanks

Best Answer chosen by Admin (Salesforce Developers) 
KapilCKapilC

HI

 

You can use this syntax.

 

<apex:outputText style="color:{!IF(status__c == fail,Red,Green)}">{!status__c}</apex:outputText>

 

[If you got answer from my post please mark it as solution.]

 

Thanks.

KapiL

All Answers

KapilCKapilC

HI

 

You can use this syntax.

 

<apex:outputText style="color:{!IF(status__c == fail,Red,Green)}">{!status__c}</apex:outputText>

 

[If you got answer from my post please mark it as solution.]

 

Thanks.

KapiL

This was selected as the best answer
SFDC_BeginerSFDC_Beginer

Can u plz resend the correct syntax!

 

It is asking a property in apex class.

 

Thanks

KapilCKapilC

HI

 

Write this one..

 

<apex:outputText style="color:{!IF(status__c == 'fail','Red','Green')}">{!status__c}</apex:outputText>

 

Thanks.

KapiL