+ Start a Discussion
theitdeptrockstheitdeptrocks 

HTML as part of an IF or CASE

Hi all,

 

I'm trying to build a VF page in which some of the formatting changes depending on the result of IF and CASE statements.  As part of the true or false results, I'm trying to add line breaks <br />, include links <a href...>, or even throw in some images.  I am currently presented with this error:

 

Syntax error. Found '<'

 

Example code:

If(MyField__c = 'Pass', <a href="www.myurl.com">You passed!</a>,'')

 

Any ideas?

Best Answer chosen by Admin (Salesforce Developers) 
ngabraningabrani

You may want to code something like -

 

<apex:outputPanel rendered="{!IF(condition here), true,false)}">

    ... Add HTML link here that you want to conditionally render.

</apex:outputPanel>

 

All Answers

ngabraningabrani

You may want to code something like -

 

<apex:outputPanel rendered="{!IF(condition here), true,false)}">

    ... Add HTML link here that you want to conditionally render.

</apex:outputPanel>

 

This was selected as the best answer
theitdeptrockstheitdeptrocks

Jackpot!  Exactly what I was looking to do.  Thanks for your help!!!