Monday, December 11, 2006

Cleaning Input in ColdFusion

I have to do some work with ColdFusion from time to time. Here an example of how to clear the input for a list of integers to be passed to a database:
<cfparam name="category_id" default="">
<cfoutput>category_id: #category_id#</cfoutput>
<cfset clean_cat=" arrayNew(1)">
<cfloop index="ListElement" list="#category_id#">
<cfif>
<cfset x=" ArrayAppend(clean_cat,">
</cfset>
</cfif>
</cfloop>
<!--- clean out here --->
<cfoutput>clean_cat: #ArrayToList(clean_cat, ',')#</cfoutput>

No comments: