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
JamalBJamalB 

visualforce change text color conditionally

I am trying to change the text color on a visualforce page to one of four colors based on data contained in a field.  The code is below.  I have looked at similar posts but have not been successful. I would appreciate any help you could provide.

<apex:repeat value="{!wrappedSystems}" var="s">
                                <tr class="linkable">
                                    <input type="hidden" class="id" data-type="system" data-id="{!s.sys.Id}" />
                                    <td><c:RC_Donut theName="{!s.sys.Id}" percent="{!s.batRemaining}" /></td>
                                    <td>{!s.sys.System_Name__c}</td>
                                    <td><center><font color = "{if({!s.sys.Operational_Status_Color__c}='Red',#FF0000, if({!s.sys.Operational_Status_Color__c}='Yellow',#FFF000, if({!s.sys.Operational_Status_Color__c}='Green',#01DF01,#808080)))}">{!s.sys.Operational_Status__c}</font></center></td>
                                    <td>{!s.sys.Status__c}</td>
                                    <td>{!s.sys.System_City__c}, {!s.sys.System_State__c}</td>
                                </tr>
                            </apex:repeat>


Prakash NawalePrakash Nawale
Hi JamalB,

Can you try with style attribute logic as

<div style="color:{if({!s.sys.Operational_Status_Color__c}='Red',#FF0000, if({!s.sys.Operational_Status_Color__c}='Yellow',#FFF000, if({!s.sys.Operational_Status_Color__c}='Green',#01DF01,#808080)))}"> Text to Display</div>


Please mark this as best answer, if this helps to you.
mukesh guptamukesh gupta
Hi JamalB,

I have test this code. it's working 100% .Please use
 
<apex:page standardcontroller="Account"> 
<apex:pageBlock> 
<apex:pageBlockTable value="{!account}" var="item"> 
<apex:column> 
<font color="{!if(item.name='Burberry','#ff0000','#00ff00')}"> 
<apex:outputtext value="{!item.name}" /> 
</font> 
</apex:column> 
</apex:pageBlockTable> 
</apex:pageBlock> 
</apex:page>

Please MARK AS BEST ANSWER!!!

Regards
Mukesh