John,

See if this helps... One method (often used in Fusebox apps) for 
forms is to set up three loops to initialize your variables. You 
normally start out with a fieldlist:

<CFSET fieldlist="field1, field2, field3"> etc.

If you're naming your fields dynamically, you'll need to build that 
fieldlist dynamically, using loops or similar methods. Maybe 
something like this:

<CFSET fieldlist="">
<CFOUTPUT Query="MyQuery">
        <CFSET 
"field#currentrow#"="#categoryName#__#categoryID#__#categoryD
ataType#">
<CFSET fieldlist=ListAppend(fieldlist,"field#currentrow#")>
</CFOUTPUT>

Then you have 3 loops to initialize your vars depending on whether 
the user is coming to the form for the first time ("new"), for editing 
of an existing record ("query") or for tweaking of a just-submitted 
form that failed some validation test ("form").

if it's a "New" use:

<CFLOOP INDEX="fieldname" LIST="#fieldlist#">
        <CFSET TEMP = SETVARIABLE("#fieldname#","")>
</CFLOOP>

if it's a "Query" use:

<CFLOOP INDEX="fieldname" LIST="#fieldlist#">
        <CFSET 
TEMP=SETVARIABLE("#fieldname#","#evaluate("QueryName."&"#f
ieldname#")#")>
                </CFLOOP>

if it's a "form" use:

<CFLOOP INDEX="field" LIST="#ListRest(fieldlist)#">
        <CFSET TEMP = SETVARIABLE("#field#", "#evaluate("form." 
& "#field#")#")>
        </CFLOOP>

You'll need to add some conditional code to determine which of the 
three uses it is. In the Fusebox method, you'd set a flag in the 
main index.cfm file, but if you're not using Fusebox, you could 
simply test for the existence of the primary key or something like 
that.

This method sets the basic field name itself to the appropriate 
value, based on whether it's a "new", "query" or "form" use... So 
you set the form field values like this:

<INPUT TYPE="text" NAME="field1" VALUE="#field1#">

I'm sure this approach will need to be tweaked depending on how 
you're actually creating your dynamic field names, but hopefully it'll 
help.

Gene Kraybill

On 21 Jul 2001, at 21:19, John Barleycorn wrote:

> hello, i've been working on this problem for a few days and i'm not having 
> any luck solving it so i was hoping someone could help.
> 
> i'm creating form fields from a query so i have dynamically created vars 
> that are passed to my next page. on the next page the vars are checked and 
> if there is an error in input then a message is logged, the original form 
> page included and then the message is displayed. trouble is, i need to put 
> the values that the user entered back in the form fields. i can't seem to do 
> this because i have to find variables based on dynamically generated data. 
> Has anyone done this before and if so, can you tell me the best way to do 
> this. also note that my form names are a concatenation of three variables 
> (category table: categoryName__categoryID__categoryDataType) this info needs 
> to be passed to the processing page so i have to name them this way. Not 
> sure if that throws a wrench in anyone's solution. If anyone can guide me 
> i'd appreciate it. I've already exausted my knowlege. Thanks.
> 
> newbie
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to