CFLib.org – Common Function Library Project

deleteFormFields(fieldList)

Last updated June 12, 2003

author

Tom Young

Version: 1 | Requires: CF5 | Library: UtilityLib

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:

<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:

/**
 * 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);
	}
}
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Kevin Cotton added
date2ExcelDate
May 5, 2016

Raymond Camden added
CapFirst
April 25, 2016

Chris Wigginton added
loremIpsum
January 18, 2016

Gary Stanton added
calculateArrival...
November 19, 2015

Sebastiaan Naafs - van Dijk added
getDaysInQuarter
November 13, 2015

Created by Raymond Camden / Design by Justin Johnson