Some extraneous quotes and hash marks in there might be crossing you up.
Try this:

<cfset the_field =
listToArray("contact_correspondence,contact_email,contact_event_off_camp
us,")>
<cfloop index="ii" from="1" to="#arrayLen(the_field)#">
      <cfset var1=the_field[ii]>
      <cfset variables[var1] = structKeyExists(form,var1)>
 
<cfoutput>#variables.var1#:#contact_event_off_campus#</cfoutput><br>
</cfloop>

I'm not sure what #contact_event_off_campus# is supposed to be doing.

-----Original Message-----
From: daniel kessler [mailto:[EMAIL PROTECTED] 
Sent: Friday, June 02, 2006 10:48 AM
To: CF-Talk
Subject: dynamically created variables

I'm trying to dynamically create/assign variables whose names are in an
array.  I wish to create a variable with default information and if the
form version of the variable is defined (it's a checkbox coming from a
form on another page) then I'd like it to have different information.

<cfset the_field =
listToArray("contact_correspondence,contact_email,contact_event_off_camp
us,")>
<cfloop index="ii" from="1" to="#arrayLen(the_field)#">
      <cfset var1= "#the_field[ii]#">
      <cfset "#var1#" = "false">
      <cfif isDefined('form.#the_field[ii]#')>
            <cfset "#var1#" = "true">
      </cfif>
 
<cfoutput>#the_field[ii]#:#contact_event_off_campus#</cfoutput><br>
</cfloop>

Oddly to me, if the field exists - that it was a checked checkbox, the
output works fine, otherwise it gives a "variable not defined" error on
the output.  It seems to me that the variable should be defined whether
a form field existed or not since I set that before the IF.

thanks for any assistance.  I hope I described it ok.

daniel
- webtool -



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:242053
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