You need to sign in to do that
Don't have an account?

Visualforce conditional styling using CASE function
Hi,
I'm trying to change the background colour of a DIV on a VF page based on the value of a field. Since I have multiple options, it seems the best way to do this is to use the CASE function. However, I can't seem to get it to work.
I have the follwing code:
However, when I try to save, I get the following error: Error: Incorrect argument type for function 'CASE()'.
Any idea I'm doing wrong?
Thanks
I'm trying to change the background colour of a DIV on a VF page based on the value of a field. Since I have multiple options, it seems the best way to do this is to use the CASE function. However, I can't seem to get it to work.
I have the follwing code:
<div class="programstatus" style="background-color:{!CASE(program.Program_Status__c == 'Applications Open', '#67AC34', program.Program_Status__c == 'Applications Closed' , '#F12923' )}"> <apex:outputText value="{!program.Program_Status__c}"></apex:outputText> </div>
However, when I try to save, I get the following error: Error: Incorrect argument type for function 'CASE()'.
Any idea I'm doing wrong?
Thanks
Please try below code.
Mark this as BEST ANSWER if it helps you.
All Answers
Please try below code.
Mark this as BEST ANSWER if it helps you.
Try this and include "default color" code also if Program_Status__c is a picklist field.
Thank you both!