CFLib.org – Common Function Library Project

StructToHidden(struct)

Last updated March 10, 2002
Download UDF

author

Nathan Dintenfass                                 Nathan Dintenfass

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

 
Rated 1 time(s). Average Rating: 4.0

Description:
A quick way to turn a simple structure into hidden form fields.

Return Values:
Returns a string.

Example:

<cfscript>
    st = structNew();
    st.foo = "bar";
    st.another = "some stuff";
    writeOutput(htmlCodeFormat(structToHidden(st)));
</cfscript>

Parameters:

Name Description Required
struct The structure to convert. Yes

Full UDF Source:

<cfscript>
/**
* Converts a structure to hidden form fields.
*
* @param struct      The structure to convert.
* @return Returns a string.
* @author Nathan Dintenfass (nathan@changemedia.com)
* @version 1, March 10, 2002
*/

function structToHidden(struct){
    //a variable for iterating
    var key = "";
    //a variable to return stuff
    var outVar = "";
    //now loop through the form scope and make hidden fields
    for(key in struct){
        if(isSimpleValue(struct[key]))
            outVar = outVar & "<input type=""hidden"" name=""" & key & """ value=""" & htmlEditFormat(struct[key]) & """>";
    }
    return outVar;        
}
</cfscript>

Search CFLib.org


Latest Additions

Shawn Porter Shawn Porter added
DeMoronize
3 hour(s) ago

Chris Carey Chris Carey added
readPropertiesFi...
1 day(s) ago

Randy Johnson Randy Johnson added
lastDayofWeek
3 day(s) ago

Frank Marion Frank Marion added
sitemapPing
7 day(s) ago

Top Rated

James Sleeman                                     QuickSort
Rated 5.0, 3 time(s)

Barney Boisvert indentXml
Rated 5.0, 3 time(s)

Nathan Dintenfass                                 queryColumnsToSt...
Rated 5.0, 3 time(s)

Kevin Pepperman generateSsccAsn
Rated 5.0, 3 time(s)

Created by Raymond Camden / Design by Justin Johnson