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. Commented Mar 24, 2015 at 12:29
  • 1
    where exactly you want to use this ? in any specific attribute or in javascript ? Commented Mar 24, 2015 at 12:29

1 Answer 1


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')}
  • 2
    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
    Commented Mar 24, 2015 at 13:50

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