[thelist] Trim all FORM.fieldnames in ColdFusion?

Joshua Olson joshua at alphashop.net
Wed Apr 25 15:36:17 CDT 2001


This code does the same this, but may run faster:

<cfparam name="form" default="">

<cfif IsStruct(form)>
  <cfset trimmed = StructNew()>
  <cfloop collection="#form#" item="i">
    <cfset trimmed[i] = Trim(form[i])>
  </cfloop>
</cfif>

The result will be in the struct "trimmed".  Other than this, I know of no
other way.

Hope this helps,
-joshua

> -----Original Message-----
> From: thelist-admin at lists.evolt.org
> Subject: [thelist] Trim all FORM.fieldnames in ColdFusion?
>
>
> Is there a way to just Trim all of the #FORM.fieldnames# in
> ColdFusion.  Something like:
>
> <CFIF #ParameterExists(FORM.fieldnames)#>
>  <CFSET #fieldnames_processed# = "">
>  <CFLOOP INDEX="form_element" LIST="#FORM.fieldnames#">
> 	<CFIF #ListFind(#fieldnames_processed#, #form_element#)# IS 0>
> 	   <CFSET #form_element_qualified# = "FORM." & #form_element#>
> 	   <CFSET #form_element_qualified# = Trim(#form_element_qualified#)>
> 	   <CFSET #fieldnames_processed# =
> #ListAppend(#fieldnames_processed#, #form_element#)#>
>    </CFIF>
>  </CFLOOP>
> </CFIF>
>
> but that works.  :-)
>
>
> TIA
>
> Faust





More information about the thelist mailing list