?: (Conditional operator)
The conditional operator is the only _javascript_ operator that takes three
operands. This operator is frequently used as a shortcut for the if
statement.
Syntax
condition ? expr1 : expr2
Parameters
condition : an _expression_ that evaluates to true or false
expr1,expr2 : Expressions with values of any type.
Description
If condition is true, the operator returns the value of expr1; otherwise, it
returns the value of expr2. For example, to display a different message
based on the value of the isMember variable, you could use this statement:
document.write ("The fee is " + (isMember ? "$2.00" : "$10.00"))
Marlon
> -----Original Message-----
> From: Kevin [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, July 27, 2004 5:13 PM
> To: CF-Talk
> Subject: RE: HELP. CF and _javascript_ question - Thanks
>
> Hey,
>
>
>
> Does anyone know where I can get a breakdown of this syntax? I would
> love to
> learn to use this kind of shorthand when I have those long lists of if /
> thens. :-)
>
>
>
> Thanks,
>
> Kevin
>
>
>
> _____
>
> Although I am far from being a _javascript_ expert but I think
> "(val=="null")?"":val;" acts like a immediate if or IIF.
>
>
>
>
>
>
>
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]

