Can any one help me out ?Explain on ternary operator and how to use ternary operator in visual force page.Any Example .Any suggestion .Plz

  • 1
    Could you get more information for your question? At the moment it is not clear what is the problem you are facing. – Sergej Utko Mar 24 '15 at 12:29
  • 1
    where exactly you want to use this ? in any specific attribute or in javascript ? – Vamsi Krishna Mar 24 '15 at 12:29

I think there is no use case in Visualforce where it could be possible to use a ternary operator (at least all my attempts returned Error: Syntax error).

What you may want to use is an IF Function:

IF(logical_test, value_if_true, value_if_false)


{!IF(someVariable == 'OK', 'it is ok', 'not ok')}
| improve this answer | |
  • 1
    I'd go so far as to say that the IF statement is a ternary operator, as it always requires three parameters, and the two branches must return compatible data types in at least most cases, making it identical in behavior with only a 4 character "penalty" over a ?: operator. – sfdcfox Mar 24 '15 at 13:50

Not the answer you're looking for? Browse other questions tagged or ask your own question.