+ Start a Discussion

change the color in if condition


I'm new with visualforce.

I want that the true value ( messagge1_true) of this condition will be in a custom color , for example yellow



<apex:page standardController="opportunity" >

    <b>{!IF(contains(opportunity.custom_fields__c, "testvalue"), "messagge1_true", "messagge2_false")}</b>

 I try to put <apex:outputText color="yellow"> before the " <b> " and </apex:outputtex> after "</b>"  but doesn't work....

I try to read salesforce_pages_developers_guide.pdf but I find only the way of <style> tag with html but doesn't work too





There are a number of ways you might do this.  Assuming you don't want to use a custom controller or extension, one possibility is  something like


<apex:outputText escape='false' value="{!if(contains(opportunity.custom_fields__c, "testvalue"),'<span style=\"color:yellow\">message1 true</span>','message2 false')}" />


Note the escalpe=false.  Use caution with this... ok as long as you re sure that the messages do not contain any unintended markup that might allow cross site scripting attacks. 




Thanks for the syntax, but in this way I have the outputtex every time "message2 false".


If I change the value of custom fields into "testvalue" or "testvalueeeeeeeeee" I have every time this output "message 2 false".


Maybe is ther some error in if ?