• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1179
  • Last Modified:

<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>
0
Judy Deo
Asked:
Judy Deo
  • 2
3 Solutions
 
pinaldaveCommented:
<cfset keyvalue = #evaluate(key)#>  
see if that works...
<cfset keyvalue = #evaluate('key')#>  
0
 
mrichmonCommented:
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
 
mrichmonCommented:
or you may need:
<cfset keyvalue = form["#key#"]>

depending on what you are trying to get here
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now