0
<tr>
     <td width="100%" colspan="18" ><table style="width:100%;" class="tr2"> 
           <tr style="font-size:10px;vertical-align:middle;">
                              <td width="20%" height="25px" style="text-align:center;border-left:hidden;">&nbsp;<b>Task Category</b>
                <apex:OutputText value="{!jobSafety.Task__c}" 
                   styleClass="{if(Record.Task__c == "Ind-Agriculture","background-color:#FFCC33;",if(Record.Task__c == "Auto-Truck-Bus","background-color:#FFCC33;"))}"/>  
                  </td>   
              <td width="20%" height="25px" style="text-align:center;" >&nbsp;Ind-Agriculture </td>    
              <td width="20%" height="25px" style="text-align:center;" >&nbsp;Auto-Truck-Bus</td> 
         <td width="20%" height="25px" style="text-align:center;">&nbsp;Ind-Other </td>   
        <td  width="20%" height="25px" style="border-right: 1px solid white; text-align:center;">&nbsp;Fire Pump </td>  </tr></table></td>
 </tr>

i am using output text to highlight values based on if condition but i am getting output text must have end tag but the end tag is already there

1
  • 2
    You are missing an exclamation mark in the styleClass definition.
    – Ranga
    Oct 17, 2018 at 13:55

1 Answer 1

3

The " character is being used as a delimiter in Visualforce so can't be used in the body of e.g.:

styleClass="{! if(Record.Task__c == "Ind-Agriculture"...

as the page processor thinks the second " it gets to is the end of the expression string for the styleClass attribute.

One solution is to switch to the alternate ' string delimiter inside the expression:

styleClass="{! if(Record.Task__c == 'Ind-Agriculture'...

PS

And to quote sfdcfox (and Ranga): "Don't forget the !".

3
  • 2
    Don't forget the !.
    – sfdcfox
    Oct 17, 2018 at 13:56
  • @sfdcfox I certainly had...
    – Keith C
    Oct 17, 2018 at 13:56
  • Also make sure applybodytag attribute set false in page tag. Oct 17, 2018 at 14:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .