b1nary0mega
8/24/2015 - 4:12 PM

Loop through a query and replace html elements with their codes

Loop through a query and replace html elements with their codes

<cfloop index="k" list="#MyQueryName.columnlist#">
  <cfset thisValue = MyQueryName[k][1]>
  <cfset thisValue = replace(thisValue,"<","&lt;","ALL")>
  <cfset thisValue = replace(thisValue,">","&gt; ","ALL")>
  <cfset thisValue = replace(thisValue,"'","&acute;","ALL")>
  <cfset thisValue = replace(thisValue,'"',"&quot;","ALL")>
  <cfset MyQueryName[k][1] = thisValue>
  <cfset my_struct[k] = MyQueryName[k][1]>
</cfloop>