CFLib.org – Common Function Library Project

FormToHidden([excludeList])

Last updated March 11, 2002

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

 
Rated 2 time(s). Average Rating: 5.0

Description:
This is a quick way to change all FORM variables into hidden fields in another form. It is particularly useful in multi-step forms where you want to pass things on from previous forms in the current form.

Return Values:
Returns a string.

Example:

view plain print about
<cfset form.test = 2>
<cfset form.foo = 1>
<cfoutput>
#htmlCodeFormat(formToHidden("gogoSubmit"))#
</cfoutput>

Parameters:

Name Description Required
excludeList A list of keys not to copy from the Form scope. Defaults to, and always includes, FIELDNAMES. No

Full UDF Source:

view plain print about
<cfscript>
/**
 * Converts the Form structure to hidden form fields.
 * 
 * @param excludeList      A list of keys not to copy from the Form scope. Defaults to, and always includes, FIELDNAMES. 
 * @return Returns a string. 
 * @author Nathan Dintenfass (nathan@changemedia.com) 
 * @version 1, March 11, 2002 
 */

function formToHidden(){
    //a variable for iterating
    var key = "";
    //should we exlude any?  by default, no
    var excludeList = "FIELDNAMES";
    //a variable to return stuff
    var outVar = "";
    //if there is an argument, it is a list to exclude
    if(arrayLen(arguments))
        excludeList = excludeList & "," & arguments[1];
    //now loop through the form scope and make hidden fields
    for(key in form){
        if(NOT listFindNoCase(excludeList,key))
            outVar = outVar & "<input type=""hidden"" name=""" & key & """ value=""" & htmlEditFormat(form[key]) & """>";
    }
    return outVar;        
}
</cfscript>
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Tayo Akinmade Tayo Akinmade added
arrayTrim
11 day(s) ago

Will Belden Will Belden added
longTime
17 day(s) ago

James Sleeman James Sleeman added
quickSort
27 day(s) ago

Ben Forta Ben Forta added
GetHostAddress
29 day(s) ago

Top Rated

Darwan Leonardo Sitepu EksporSQLData
Rated 5.0, 16 time(s)

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

Barney Boisvert indentXml
Rated 5.0, 10 time(s)

Kevin Pepperman generateSsccAsn
Rated 5.0, 4 time(s)

Created by Raymond Camden / Design by Justin Johnson