<cfset inside <cfloop

i have the below code which is on a page that is receiving a form post. it seems to stop working whenever i include the <cfset...> tags. i am not able to view the error page because it is a different server that is submitting to this page. anways, i guess my question is, is there some reason i can't use <cfset..> tags inside the <cfloop..> tag..

<cfmail to="asdf@asdf.com" from="asdf@asdf.com" subject="test">

  <CFLOOP item="key" collection="#form#">
 
  <cfset keyvalue = #form[key]#>  
 
  key is #key# <br />
  keyvalue is: #keyvalue# <br />
 
  <cfif #key# eq "customernumber">
  <cfset customernumber = #keyvalue#>
  <cfelse>
  </cfif>
   
  <cfif #key# eq "amountdue">
  <cfset amountdue = #keyvalue#>
  <cfelse>
  </cfif>
 
  </CFLOOP>
 
</cfmail>
Judy DeoAsked:
Who is Participating?
 
mrichmonConnect With a Mentor Commented:
there is no problem using cfset in a loop.

I think it is like your last question

Try

<CFLOOP item="key" collection="#form#">

<cfset keyvalue = form[key]>

key is #key# <br />
  keyvalue is: #keyvalue# <br />

 <cfif key eq "customernumber">
  <cfset customernumber = keyvalue>
  <cfelse>
  </cfif>
   
  <cfif key eq "amountdue">
  <cfset amountdue = keyvalue>
  <cfelse>
  </cfif>
 
  </CFLOOP>
0
 
pinaldaveConnect With a Mentor Commented:
<cfset keyvalue = #evaluate(key)#>  
see if that works...
<cfset keyvalue = #evaluate('key')#>  
0
 
mrichmonConnect With a Mentor Commented:
or you may need:
<cfset keyvalue = form["#key#"]>

depending on what you are trying to get here
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.