[thelist] CF: Values from Dynamically Generated Col Names?!

Frank lists at frankmarion.com
Sun Jan 4 05:39:01 CST 2004


I've got a situation where I've had to generate a "spreadsheet" (It's 
nothing more than a very large check list with 'x' or '' as the data), and 
I use a loop to build the table's columns. Each column contains a text 
input. The database (unfortunately) has 100 columns from c_001 to c_100, as 
does the spreadsheet.

Row 1:  [c_001] [c_002] ... [c_100]


Each row is generated by a queried loop as well. Thus, for every row, we 
are using a loop to create 100 columns.

Apples:         [c_001] [c_002] ... [c_100]
Oranges:        [c_001] [c_002] ... [c_100]
Pears:          [c_001] [c_002] ... [c_100]


My problem is that each text input must read the value from the database 
and insert the appropriate value for each cell. The only way to achieve 
this is to dynamically generate the name of the value. I can easily build 
the variable name but not display the query's value


Abreviate code as follows

<cfloop query="categories"> <!--- Builds the rows --->

    <cfloop index="cnt" from="1" to="100"> <!--- Builds the columns --->

       <cfset cell_name="c_#NumberFormat(cnt, '000')#">
       <input type="text" name="#cell_name#" value="#cell_name#">

    </cfloop>

</cfloop>


I've tried a variety of absurdities such as 
#Evaluate(DE('categories.'&cell_name))# with no luck. Ideally, the correct 
behaviour would be that when the document loads, that correct query values 
are inserted into the text-input field ('x' or '').

Any help would be truly appreciated. This one is hammering me.


--
Frank Marion     lists at frankmarion.com      Keep the signal high.  



More information about the thelist mailing list