You don't need the de() around numeric values or true and false, so
either of these would also work:

iif(condition,1,0)
iif(condition,true,false)

de() is only necessary if you provide a string value and either
evaluate(string) would produce an error or you don't want the string
to be evaluated, so this also works:

mike = true;
simon = false;
iif(condition,"mike","simon");

and would produce a value of true or false
you would then use de() if you wanted the iif() to produce the values
"mike" or "simon".

and of course you can combine them:

iif(condition,"mike",false);

hth

> Thanks Michael,  that works!     I'm talking about using
> the new CFMX7
> CFFORM structures.  In fact I'm using the XML forms.

> Here's how I can code the same options I had earlier, now
> using Michael's
> delayed evaluate technique,

> <cfformgroup type="horizontal" label="Preferred Payment
> Method:">
>  <cfinput type="radio" name="PaymentMethod" value="Visa"
>  Label="Visa"
>                       checked="#iif(order.getpaymentmethod
>                       () IS
> 'Visa',de('true'),de('false'))#" >
>   <cfinput type="radio" name="PaymentMethod"
>   value="Mastercard"
> Label="Mastercard"
>                    checked="#iif(order.getpaymentmethod()
>                    IS
> 'Mastercard',de('true'),de('false'))#" >
>   <cfinput type="radio" name="PaymentMethod" value="Amex"
>   Label="Amex"
>                     checked="#iif(order.getpaymentmethod()
>                      IS
> 'Amex',de('true'),de('false'))#" >
> </cfformgroup>


> Now it's all in  5 lines of code  instead of 15 lines, and
> the range of
> options is listed only once.  In a set of radio buttons
> where there are for
> example 20 choices, this would make a huge difference to
> the amount of work,
> typing, coding and future maintenance.

> Cheers
> Mike Kear
> Windsor, NSW, Australia
> Certified Advanced ColdFusion Developer
> AFP Webworks
> http://afpwebworks.com
> ColdFusion, PHP, ASP, ASP.NET hosting from AUD$15/month



> On 3/20/06, Michael Traher <[EMAIL PROTECTED]>
> wrote:
>>
>> You could use #iif(order.getpaymentmethod() IS
>> 'VISA',de('checked'),de(''))#
>> in the checked attribute value.
>>
>> Not quite what you meant I know but would be neater than
>> lots of
>> <cfif><cfelse> constructs.
>>
>> HTH
>> --
>> Mike T
>> Blog http://www.socialpoints.com/
>>


> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:235735
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to