CFLib.org – Common Function Library Project

deleteFormFields(fieldList)

Last updated June 12, 2003

Version: 1 | Requires: ColdFusion 5 | Library: UtilityLib

 
Rated 0 time(s). Average Rating: 0

Description:
Useful if you need to clean up a form for whatever reason before using the cfinsert or cfupdate tag. Takes a comma-delimited list of form field names as its only argument.

Return Values:
Returns nothing.

Example:

view plain print about
<cfset form.field1 = "foo">
<cfset form.field2 = "goo">
<cfset form.field3 = "zoo">
<cfset form.fieldnames="field1,field2,field3">
<cfdump var="#form#">
<cfset theFields = "field1,field2">
<cfset deleteFormFields(theFields)>
<cfdump var="#form#">

Parameters:

Name Description Required
fieldList List of fields to return. Yes

Full UDF Source:

view plain print about
<cfscript>
/**
 * Removes specified fields from a form structure.
 * 
 * @param fieldList      List of fields to return. (Required)
 * @return Returns nothing. 
 * @author Tom Young (tom@thenewmediagroup.com) 
 * @version 1, June 12, 2003 
 */

function deleteFormFields(fieldList) {
    var listIndex = 1;
    var i = 1;
    fieldList = ListToArray(fieldList);
    for(i = 1; i lte ArrayLen(fieldList); i = i + 1) {
        StructDelete(form, fieldList[i]);
        listIndex = ListFindNoCase(form.fieldnames, fieldList[i]);
        form.fieldnames = ListDeleteAt(form.fieldnames, listIndex);
    }
}
</cfscript>
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Dave Anderson Dave Anderson added
iniToStruct
20 day(s) ago

Dave Anderson Dave Anderson added
deDupeArray
20 day(s) ago

Richard Richard added
dice
22 day(s) ago

Isaac Dealey Isaac Dealey added
getRelative
a while ago

Top Rated

Darwan Leonardo Sitepu backupDatabase
Rated 5.0, 22 time(s)

Barney Boisvert indentXml
Rated 5.0, 10 time(s)

Kevin Pepperman generateSsccAsn
Rated 5.0, 4 time(s)

Raymond Camden highlightAndCrop
Rated 5.0, 4 time(s)

Created by Raymond Camden / Design by Justin Johnson