I have some code that loops over a list of fields to cfparam some attributes. The idea is, if the query (getCust) returns a record, set the attribute to the query.column value; if no record, set the attribute to null. After some hacking around I got it to work as desired, but I don't quite understand how.
<cfset fieldlist = "Customer_ID,FirstName,LastName,Email,Address1,Address2,City,State,State2,Zip,Country,Phone"> <cfloop list="#fieldlist#" index="i"> <cfset temp = iif(didquery and didfind, "getCust.#i#", DE(""))> <cfparam name="attributes.#i#" default="#temp#"> </cfloop> What I don't get is how iif works. It seems to do the following: - Doesn't evaluate "getCust.#i#" when the page is compiled - Assuming the iif conditional evaluates true, when the list is looped, first evaluates just the "#i#" in "getCust.#i#" to return the proper field name, then evaluates the variable "getCust.FirstName" (for example) to return the correct value. So there is sort of a double evaluation going on. Am I understanding iif correctly or does someone have a better explanation as to how it works. The docs are kind of hard to fathom. -- Josh ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting, up-to-date ColdFusion information by your peers, delivered to your door four times a year. http://www.fusionauthority.com/quarterly Archive: http://www.houseoffusion.com/cf_lists/message.cfm/forumid:4/messageid:247345 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4