> I need a way of reading form fields on a dynamic basis through a loop.
>
> Ie.  Form fields: Qty1 - Qty6, Main1 - Main6, Block1 - Block6 etc etc
>
> Rather than having 6 almost identical blocks of code to handle each set of
> fields I'd like to just run through a CFLOOP 6 times.  The fields are
> created in this way on the previous template (see below) but I'm unsure of
> the syntax to actually read the fields on the subsequent (if it is
> possible).
>
> <cfloop index="i" from="1" to="6">
>                       <cfinput name="Qty#i#">.....etc

If you're gonna use loops, use 2 loops
<cfloop index="j" list="Qty,Main,Block">
        <cfloop index="i" from=1 to=6>
                <cfinput name="#j##i#">
        </cfloop>
</cfloop>

Seeing as the fields are dynamic, you can read them using Evaluate();
<cfloop index="j" list="Qty,Main,Block">
        <cfloop index="i" from=1 to=6>
                <cfif Evaluate("#j##i#") is "">
                        This field is empty
                </cfif>
        </cfloop>
</cfloop>

Or to set this field to be something;
                <cfset "#j##i#"=myValue>

Variable name flexibility is a wonderful thing

Philip Arnold
ASP Multimedia Limited
T: +44 (0)20 8680 1133

"Websites for the real world"

**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.
**********************************************************************


------------------------------------------------------------------------------
Archives: http://www.mail-archive.com/[email protected]/
To Unsubscribe visit 
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or send a 
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.

Reply via email to