I know you said you tried evaluate but in this case it would seem to be the way to go. 
 What was the output?  Did you get the syntax wrong?  Why is it that evaluate didn't 
work for you?

Assuming there will always be at least one material....
[psuedocode - you fill in the cf tags]

sql = "insert into mytable (material1"
if number_of_materials > 1
        for counter=2 to number of materials
                sql += " ,material" & counter
sql += ") values ('" & mat_value1 & "'"
if number_of_materials > 1
        for counter=2 to number of materials
                temp = "mat_value" & counter
                sql += " ,'" & evaluate(temp) & "'"
sql += ")"
cfquery sql

[beware the double and single quotes above.  They're hard to see but crucial.  You 
might also want to parse the values to remove single quotes and escape backslash 
before entering them into the database]

Darren




>>> [EMAIL PROTECTED] 06/07/01 03:16PM >>>

Ok...I was recently sitting in a meeting with some people in my department about an 
application I'm developing.  Seeing as I am *the* developer I could really use some 
help.  It's an estimating/billing application.  There is a possibility of twenty 
different lines for materials used and twenty slots for it to go in the database.  
Pretty simple.  I was just going to put in twenty different drop down boxes for this, 
which is the way they wanted it done.  Well, not every project will use 20 different 
materials.  Some might use 2, some might use 10, and some might use 20.  My supervisor 
(who has enough CF experience to make him dangerous sometimes) thought it looked 
cluttered like that so he said we'll let you choose how many lines you want for 
materials. "we can do that, no problem!" he says.  So I'm left to figure out how "we" 
are going to do it.

I have the form where they enter in how many lines they want, and I have the form with 
that number of lines and corresponding fields.  Not a problem yet, but now here's 
where I find my difficulty...  When I submit this form to the database I now have to 
figure out how to do the SQL submit statement where the number of variables is 
dynamic.  In my database I have the fields "material1, material2, material3, 
material4,....material20" and can build the first part of the insert statement using a 
CFLOOP, but when I come to the Values() part of the insert...how do I dynamically 
create that.

For example:  The user wanted 5 lines for materials.  On the form the user fills out 
the boxes for material1, material2, material3, material4, material5.  How do I 
dynamically create the Values('#form.material1#', '#form.material2#', 
'#form.material3#', '#form.material4#', '#form.material5#')?  I have tried the 
Evaluate function before and didn't have too much luck.

Suggestions?  It seems like the whole project hinges on this dynamic variables problem.

Thank you...thank you....thank you!



---------------------------------
Do You Yahoo!?
Yahoo! Mail Personal Address - Get email at your own domain with Yahoo! Mail.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to