– Common Function Library Project


Last updated February 20, 2013


Ryan Stille

Version: 2 | Requires: CF8 | Library: UtilityLib

When you pass several form or URL variables into ColdFusion with the same name, they end up as a comma separated list. This is commonly done with checkboxes – a user can check as many items as they want, then they will end up in your code all in a single variable. This works fine, until your data contains a comma. This function will return the data as an array to get around that problem. Tested on ColdFusion 8 and 9, probably runs on CF 7 also, maybe even 6. UPDATE - rewritten to work in CF10. Code is much more simple now.

Return Values:
Returns an array.


<cfset MyFormFieldAsArray = formFieldAsArray('group_of_checkboxes') />


Name Description Required
fieldName Name of the Form or URL field Yes

Full UDF Source:

 Returns a form field as array, useful for when you have more than one form field with the same name.
 @param fieldName      Name of the Form or URL field (Required)
 @return Returns an array. 
 @author Ryan Stille ( 
 @version 2, February 19, 2013 
<cffunction name="formFieldAsArray" returntype="array" output="false" hint="Returns a Form/URL variable as an array.">
    <cfargument name="fieldName" required="true" type="string" hint="Name of the Form or URL field" />
    <cfset var content = getHTTPRequestData().content />
    <cfset var returnArray = arrayNew(1) />
    <cfloop list="#content#" delimiters="&" index="local.parameter">
        <cfif listFirst(local.parameter,"=") EQ arguments.fieldName>
            <cfif ListLen(local.parameter,"=") EQ 2>
                <cfset arrayAppend(returnArray,URLDecode(listLast(local.parameter,"="))) />
                <cfset arrayAppend(returnArray,"") />
    <cfreturn returnArray />



Latest Additions

Raymond Camden added
November 04, 2017

Leigh added
May 11, 2016

Raymond Camden added
May 10, 2016

Kevin Cotton added
May 05, 2016

Raymond Camden added
April 25, 2016

Created by Raymond Camden / Design by Justin Johnson