Yes it does help, Isaac.    You're right.  And I had learned that about iif,
but since I never had use for it before, it was away in the dusty corners of
my memory.   Now the code is even more concise, to replace the 15 lines of
code in my original post,  and boils down to this:

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


I think the new XML forms would have to be one of the least publicised
wonders of CFMX7.  It's revolutionised the way I collect data.

And if you put the skin attribute as a application variable,  you can
standardise the look of forms all over your site,  and change the whole look
everywhere with the change of a single variable.     For example:

in Application.cfm or Application.cfc   have the following somewhere:
<cfset application.formskin = "blue" />

Then in every form on the site you have this as the <cfform tag:

<cfform action="#cgi.script_name#?#cgi.Query_string#" method="post"
name="whatever" format="XML" skin="#application.formskin#">

stuff
</cfform>

Change the value of application.formskin and behold!  All the forms on your
site change their look and feel together.   Easy code reuse!

WONDERFUL!!


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, S. Isaac Dealey <[EMAIL PROTECTED]> wrote:
>
> 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:235737
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=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to