Dynamic Variable Names

2001-01-16 Thread Martin S

Hi,

In this example I have two pages...with a form post inbetween.

The first page has a lot of text boxes called ID1 to ID16 (so, 16 in total 
;) ).these boxes are in a database loop (thus the number to 
differentiate them).  Also over time the number may change from 16 to 18 
etc..so there may be more text boxes.

I also pass this total number (16) to the second page in a hidden field.

On the second page I want to evaluate the value for each one..but as the 
total number is not a constant I need to do a loop.

The following code is what I have come up with :


  
#I#


 #varname# = Custom
  


.end code.

What this is SUPPOSED to be doing is checking if the passed VALUE for 
Form.ID1 (through 16) equals "Custom", and if so it does something, else 
something else...

but what it is doing is a literal comparison, so there are NEVER any true 
results to the if statement, when infact with my current code 11 out of 12 
should return true.

Can someone help me with this...it may be trivial to some of you..but I need 
to get around this ASAP.

Thanks heaps!!!
~~
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



Dynamic Variable Names

2001-05-03 Thread Jenny Anderson

I want to dynamically create a variable name based upon a url variable.
First I set up a couple of strings:



Where q is a number from 1-37 passed via url variable.  Let's say that 
url.q is 7.  Then qn is 'q7'.
So I query the database like this:


   SELECT #qn#
   FROM database


And it correctly pulls all the results from the 'q7' column.  So far so good.
But now I want to be able to manipulate the query results and refer to the 
q7's from the database query.  If I refer to #qn# I only get q7 as the 
result.  So how do I have it refer to the variable q7 and not the string q7?

Thanks!

Jenny


~~
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



Dynamic variable names

2001-05-24 Thread Andy Ewings

Can you have dynamic variable names in CF?e.g in an action page could
you have something like - 







where there are form fileds fieldnum1, fieldnum2, and fieldnum3.

I have tried this but it doesn't work.I thought you might be able to use
the Evaluate function in this way as this works (from the Forta book):




This creates a new array stored in the variable p

~~
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



Dynamic Variable Names

2001-06-07 Thread Jen R


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 youthank 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



RE: Dynamic Variable Names

2001-01-16 Thread Raymond B.

  You're trouble is you're not using the evaluate() function (and you're
using # gratuitously :).



  This will now be the value of from.id1 instead of the string "form.id1"
(through whatever). There are other ways to handle this as well.

  One thing of note is instead of using the for style cfloop, use a while
(conditional) loop and you won't have to pass the number along, just add a
counter.













  This will now run from x to the first break in the ints up from it; so 1
until whatever you decide w/o you having to pass a number.

  Alternately, if it's all logic you might want to use cfscript.


x = 1;

while (isDefined("form.id" & x)) {
  field = evaluate("form.id" & x) ;
if (field eq "Custom") {
  // do this is custom
} else {
  // do this if not
  }
  x = x + 1 ;
  }


-Original Message-
From: Martin S [mailto:[EMAIL PROTECTED]]
Sent: January 16, 2001 21:22
To: CF-Talk
Subject: Dynamic Variable Names


Hi,

In this example I have two pages...with a form post inbetween.

The first page has a lot of text boxes called ID1 to ID16 (so, 16 in total
;) ).these boxes are in a database loop (thus the number to
differentiate them).  Also over time the number may change from 16 to 18
etc..so there may be more text boxes.

I also pass this total number (16) to the second page in a hidden field.

On the second page I want to evaluate the value for each one..but as the
total number is not a constant I need to do a loop.

The following code is what I have come up with :


  
#I#


 #varname# = Custom
  


..end code.

What this is SUPPOSED to be doing is checking if the passed VALUE for
Form.ID1 (through 16) equals "Custom", and if so it does something, else
something else...

.but what it is doing is a literal comparison, so there are NEVER any
true
results to the if statement, when infact with my current code 11 out of 12
should return true.

Can someone help me with this...it may be trivial to some of you..but I need
to get around this ASAP.

Thanks heaps!!!
~~
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



Re: Dynamic Variable Names

2001-05-03 Thread Tony Schreiber

#Evaluate(qn)#

> I want to dynamically create a variable name based upon a url variable.
> First I set up a couple of strings:
> 
> 
> 
> Where q is a number from 1-37 passed via url variable.  Let's say that 
> url.q is 7.  Then qn is 'q7'.
> So I query the database like this:
> 
> 
>SELECT #qn#
>FROM database
> 
> 
> And it correctly pulls all the results from the 'q7' column.  So far so good.
> But now I want to be able to manipulate the query results and refer to the 
> q7's from the database query.  If I refer to #qn# I only get q7 as the 
> result.  So how do I have it refer to the variable q7 and not the string q7?
> 
> Thanks!
> 
> Jenny
> 
> 
>
~~
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



RE: Dynamic Variable Names

2001-05-04 Thread Semrau, Steven L Mr SRA

Try referring to it as get_results.#qn#

Steven Semrau
SRA International, Inc.
Senior Member, Professional Staff
[EMAIL PROTECTED]
[EMAIL PROTECTED]
Com:  (703) 805-1095
DSN:  (703) 655-1095


-Original Message-
From: Jenny Anderson [mailto:[EMAIL PROTECTED]]
Sent: Thursday, May 03, 2001 2:42 PM
To: CF-Talk
Subject: Dynamic Variable Names


I want to dynamically create a variable name based upon a url variable.
First I set up a couple of strings:



Where q is a number from 1-37 passed via url variable.  Let's say that 
url.q is 7.  Then qn is 'q7'.
So I query the database like this:


   SELECT #qn#
   FROM database


And it correctly pulls all the results from the 'q7' column.  So far so
good.
But now I want to be able to manipulate the query results and refer to the 
q7's from the database query.  If I refer to #qn# I only get q7 as the 
result.  So how do I have it refer to the variable q7 and not the string q7?

Thanks!

Jenny
~~
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



Re: Dynamic Variable Names

2001-05-04 Thread Joshua Meekhof

assuming that once you have retrieved the record the value of qn is no
significant, try alias the value in the query:
 
SELECT #qn# as foo
FROM database
 



Jenny Anderson wrote:
> 
> I want to dynamically create a variable name based upon a url variable.
> First I set up a couple of strings:
> 
> 
> 
> Where q is a number from 1-37 passed via url variable.  Let's say that
> url.q is 7.  Then qn is 'q7'.
> So I query the database like this:
> 
> 
>SELECT #qn#
>FROM database
> 
> 
> And it correctly pulls all the results from the 'q7' column.  So far so good.
> But now I want to be able to manipulate the query results and refer to the
> q7's from the database query.  If I refer to #qn# I only get q7 as the
> result.  So how do I have it refer to the variable q7 and not the string q7?
> 
> Thanks!
> 
> Jenny
> 
>
~~
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



RE: Dynamic Variable Names

2001-05-04 Thread Diana Nichols

Or, another solution is to reference #evaluate(qn)#, which will give you the
query result.
D
*
Diana Nichols
Webmistress
http://www.lavenderthreads.com
770.434.7374

"One man's magic is another man's engineering." ---Lazarus Long

-Original Message-
From: Joshua Meekhof [mailto:[EMAIL PROTECTED]]
Sent: Friday, May 04, 2001 1:38 PM
To: CF-Talk
Subject: Re: Dynamic Variable Names


assuming that once you have retrieved the record the value of qn is no
significant, try alias the value in the query:
 
SELECT #qn# as foo
FROM database
 



Jenny Anderson wrote:
>
> I want to dynamically create a variable name based upon a url variable.
> First I set up a couple of strings:
> 
> 
>
> Where q is a number from 1-37 passed via url variable.  Let's say that
> url.q is 7.  Then qn is 'q7'.
> So I query the database like this:
>
> 
>SELECT #qn#
>FROM database
> 
>
> And it correctly pulls all the results from the 'q7' column.  So far so
good.
> But now I want to be able to manipulate the query results and refer to the
> q7's from the database query.  If I refer to #qn# I only get q7 as the
> result.  So how do I have it refer to the variable q7 and not the string
q7?
>
> Thanks!
>
> Jenny
>
>
~~
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



Re: Dynamic Variable Names

2001-05-04 Thread Jose Alberto Guerra Ugalde

I havent tried this but according to Michael Dinowitz it should be like
this:

Dynamic Variables

The Variable portion of a CFSET can be set dynamically by placing the text
portion within double quotes (") and surrounding the dynamic portion with
pound signs (#).
The Variable part of a CFSET does not need pound signs unless you're setting
a dynamic variable name, in which case it should be inside double quotes (")
as well.

Wrong: 
Right: 

When setting a dynamic Variable in a CFSET, remember to place the entire
Variable within double quotes (").

Wrong: 
Wrong: 
Right: 
Right: 

Regards.

- Original Message -
From: "Diana Nichols" <[EMAIL PROTECTED]>
To: "CF-Talk" <[EMAIL PROTECTED]>
Sent: Friday, May 04, 2001 12:07 PM
Subject: RE: Dynamic Variable Names


> Or, another solution is to reference #evaluate(qn)#, which will give you
the
> query result.
> D
> *
> Diana Nichols
> Webmistress
> http://www.lavenderthreads.com
> 770.434.7374
>
> "One man's magic is another man's engineering." ---Lazarus Long
>
> -Original Message-
> From: Joshua Meekhof [mailto:[EMAIL PROTECTED]]
> Sent: Friday, May 04, 2001 1:38 PM
> To: CF-Talk
> Subject: Re: Dynamic Variable Names
>
>
> assuming that once you have retrieved the record the value of qn is no
> significant, try alias the value in the query:
>  
> SELECT #qn# as foo
> FROM database
>  
>
>
>
> Jenny Anderson wrote:
> >
> > I want to dynamically create a variable name based upon a url variable.
> > First I set up a couple of strings:
> > 
> > 
> >
> > Where q is a number from 1-37 passed via url variable.  Let's say that
> > url.q is 7.  Then qn is 'q7'.
> > So I query the database like this:
> >
> > 
> >SELECT #qn#
> >FROM database
> > 
> >
> > And it correctly pulls all the results from the 'q7' column.  So far so
> good.
> > But now I want to be able to manipulate the query results and refer to
the
> > q7's from the database query.  If I refer to #qn# I only get q7 as the
> > result.  So how do I have it refer to the variable q7 and not the string
> q7?
> >
> > Thanks!
> >
> > Jenny
> >
> >
>
~~
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



RE: Dynamic variable names

2001-05-24 Thread DeVoil, Nick

How about






Nick

-Original Message-
From: Andy Ewings [mailto:[EMAIL PROTECTED]]
Sent: Thursday, May 24, 2001 4:23 PM
To: CF-Talk
Subject: Dynamic variable names


Can you have dynamic variable names in CF?e.g in an action page could
you have something like - 







where there are form fileds fieldnum1, fieldnum2, and fieldnum3.

I have tried this but it doesn't work.I thought you might be able to use
the Evaluate function in this way as this works (from the Forta book):




This creates a new array stored in the variable p


**
Information in this email is confidential and may be privileged. 
It is intended for the addressee only. If you have received it in error,
please notify the sender immediately and delete it from your system. 
You should not otherwise copy it, retransmit it or use or disclose its
contents to anyone. 
Thank you for your co-operation.
**

~~
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



RE: Dynamic variable names

2001-05-24 Thread Dylan Bromby

yes you can do it. i use Evaluate() with dynamic values all the time.

try removing the " from "#id#". if that doesn't work (it should), try
something like:








-Original Message-
From: Andy Ewings [mailto:[EMAIL PROTECTED]]
Sent: Thursday, May 24, 2001 8:23 AM
To: CF-Talk
Subject: Dynamic variable names


Can you have dynamic variable names in CF?e.g in an action page could
you have something like -







where there are form fileds fieldnum1, fieldnum2, and fieldnum3.

I have tried this but it doesn't work.I thought you might be able to use
the Evaluate function in this way as this works (from the Forta book):




This creates a new array stored in the variable p
~~
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



RE: Dynamic variable names

2001-05-24 Thread Raymond Camden

If you want a form field, why use Evaluate? Just treat the form field as a
struct key.

 
 



 

or even shorter...

 
 


 

===
Raymond Camden, Principal Spectra Compliance Engineer for Macromedia

Email   : [EMAIL PROTECTED]
ICQ UIN : 3679482

"My ally is the Force, and a powerful ally it is." - Yoda

> -Original Message-
> From: Dylan Bromby [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, May 24, 2001 12:22 PM
> To: CF-Talk
> Subject: RE: Dynamic variable names
>
>
> yes you can do it. i use Evaluate() with dynamic values all the time.
>
> try removing the " from "#id#". if that doesn't work (it should), try
> something like:
>
> 
> 
>   
>   
>   
> 
>
> -Original Message-
> From: Andy Ewings [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, May 24, 2001 8:23 AM
> To: CF-Talk
> Subject: Dynamic variable names
>
>
> Can you have dynamic variable names in CF?e.g in an action page could
> you have something like -
>
> 
> 
>   
>   
> 
>
> where there are form fileds fieldnum1, fieldnum2, and fieldnum3.
>
> I have tried this but it doesn't work.I thought you might be
> able to use
> the Evaluate function in this way as this works (from the Forta book):
>
> 
> 
>
> This creates a new array stored in the variable p
>
~~
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



RE: Dynamic variable names

2001-05-24 Thread Dave Watts

> Can you have dynamic variable names in CF?e.g in an 
> action page could you have something like - 
> 
> 
> 
>   
>   
> 

Sure, but if you want to dynamically reference form.fieldnum1, you'd want
your Evaluate function to look like this:



What this'll do is concatenate the string "form.fieldnum" with the string
contained in the variable id, then evaluate that string.

Dave Watts, CTO, Fig Leaf Software 
http://www.figleaf.com/ 
voice: (202) 797-5496 
fax: (202) 797-5444

~~
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



RE: Dynamic Variable Names

2001-06-07 Thread Jann VanOver

Here's the magic you need:
   #evaluate("form.material"&i)#

-Original Message-
From: Jen R [mailto:[EMAIL PROTECTED]]
Sent: Thursday, June 07, 2001 12:17 PM
To: CF-Talk
Subject: Dynamic Variable Names

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 youthank 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



Re: Dynamic Variable Names

2001-06-07 Thread Darren Houle

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 youthank 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



Re: Dynamic Variable Names

2001-06-07 Thread Jon Hall

The problem you are having is because of the database structure. Those
materials fields need to be in a different table with another field that
relates to the project. Any time you have a 1 to Many relationship like
these 20 materials to 1 project, it cries out for two tables.
Here is some example sql, on how you would get the records, if the table was
split into the two parts.

SELECT Projects.ProjectID, Projects.Description, Materials.Material
FROM Projects, Materials
WHERE Projects.ProjectID = #projectID#
AND Projects.ProjectID = Materials.ProjectID

This way all you have to do is insert into the Materials table a new entry
with the projectid and the material, that's it.
I hope that makes sense...

If it's too late to redesign the database, why not just cfparam all of the
form variables on the action page?

jon
- Original Message -
From: "Jen R" <[EMAIL PROTECTED]>
To: "CF-Talk" <[EMAIL PROTECTED]>
Sent: Thursday, June 07, 2001 3:16 PM
Subject: Dynamic Variable Names


>
> 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 youthank 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



RE: Dynamic Variable Names

2001-06-07 Thread Sicular, Alexander

evaluate is the least of your problems.  lets start with the database. it is
not normalized. read : http://www.swynk.com/friends/putnam/normarticle.asp
for a better explanation. basically, whenever you find yourself making
column names that end with a number, you have a non-normalized table
structure.

regardless... if you were to do say :










the submit would look like this:

value1,value2,value3,value4

you could then treat form.myselect as a list and loop over it to do the
inserts.

Alexander Sicular
Chief Technology Architect
The Neurological Institute of New York
Columbia University
212.305.1318
as867 {at} columbia [dot] edu


> -Original Message-
> From: Jen R [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, June 07, 2001 3:17 PM
> To: CF-Talk
> Subject: Dynamic Variable Names
> 
> 
> 
> 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 youthank 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



-OT- Javascript - Dynamic Variable Names

2002-10-02 Thread Thane Sherrington

If someone knows of a good Javascript list where I can ask this, let me 
know and I'll go there.  I'm trying to loop in Javascript and create a 
dynamic variable name in each loop (the way I can do a 
variablename#loopvalue# in CF.)  Any idea how I could do this?  I'm trying 
to access form fields, so if there is another way to loop through form 
fields (if they exist as an array for Javascript) that would be fine too.

T

~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
This list and all House of Fusion resources hosted by CFHosting.com. The place for 
dependable ColdFusion Hosting.



Dynamic variable names in QuerySetCell

2003-12-16 Thread Ryan Kime
I'm trying to avoid Evaluate and have hit a wall. I am trying to dynamically
call column names from qResults and set the values in a QuerySetCell - val1,
val2, val3, val4, etc...

 
Here's an example:

 



 

    
    
qResults["val"&LoopCount], LoopCount)>


The second QuerySetCell is what is killing me. It gives the wretched,
"Complex objects cannot be converted to simple values" error.

--

 
Ryan Kime
  [EMAIL PROTECTED]
Web Developer
Webco Industries
 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]




Re: -OT- Javascript - Dynamic Variable Names

2002-10-02 Thread Marlon Moyer

www.irt.org is a great resource and here's a link to an answer to your 
question:

http://developer.irt.org/script/809.htm

Marlon

Thane Sherrington wrote:

>If someone knows of a good Javascript list where I can ask this, let me 
>know and I'll go there.  I'm trying to loop in Javascript and create a 
>dynamic variable name in each loop (the way I can do a 
>variablename#loopvalue# in CF.)  Any idea how I could do this?  I'm trying 
>to access form fields, so if there is another way to loop through form 
>fields (if they exist as an array for Javascript) that would be fine too.
>
>T
>
>
~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm



Re: -OT- Javascript - Dynamic Variable Names

2002-10-02 Thread Thane Sherrington

At 06:40 AM 02/10/02 -0500, Marlon Moyer wrote:
>www.irt.org is a great resource and here's a link to an answer to your
>question:

Thanks.  That appears to have solved it.

T

~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Your ad could be here. Monies from ads go to support these lists and provide more 
resources for the community. http://www.fusionauthority.com/ads.cfm



re: Dynamic variable names in QuerySetCell

2003-12-16 Thread Scott Brady
Original Message:
> From: Ryan Kime <[EMAIL PROTECTED]>
> 
> 
> 
> qResults["val"&LoopCount], LoopCount)>
> 
>  
>  
> The second QuerySetCell is what is killing me. It gives the wretched,
> "Complex objects cannot be converted to simple values" error.

How many rows does "qResults" turn?

I think what you need is qResults["val" & loopCount][1]  to get just the first row's "val1" value (even if the query only returns 1 row).

It's just an educated guess, but it's worth a shot.

Scott

---
Scott Brady
http://www.scottbrady.net/
 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]




RE: Dynamic variable names in QuerySetCell

2003-12-16 Thread Ryan Kime
Good question Scott, the recordcount of qResults will always be 1. FYI,
adding the [1] worked! 

 
Thanks!

-Original Message-
From: Scott Brady [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, December 16, 2003 3:05 PM
To: CF-Talk
Subject: re: Dynamic variable names in QuerySetCell

Original Message:
> From: Ryan Kime <[EMAIL PROTECTED]>
> 
> 
> 
> qResults["val"&LoopCount], LoopCount)>
> 
>  
>  
> The second QuerySetCell is what is killing me. It gives the wretched,
> "Complex objects cannot be converted to simple values" error.

How many rows does "qResults" turn?

I think what you need is qResults["val" & loopCount][1]  to get just the
first row's "val1" value (even if the query only returns 1 row).

It's just an educated guess, but it's worth a shot.

Scott

---
Scott Brady
http://www.scottbrady.net/   
  _
 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]




Dynamic Variable Names in a CFSET

2000-11-02 Thread David Hannum

Hello,

What's the best way to dynamically name variables used in a CFSET tag?

I want them named choice0, choice1, etc up through however many loops are
made:

  (which does not work but illustrates what I'm
trying to do.

Thanks,
Dave


Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists or send a message 
with 'unsubscribe' in the body to [EMAIL PROTECTED]



Re: Dynamic Variable Names in a CFSET

2000-11-02 Thread Gena

Check EVALUATE and DE functions

Gennadi


- Original Message -
From: "David Hannum" <[EMAIL PROTECTED]>
To: "CF-Talk" <[EMAIL PROTECTED]>
Sent: Friday, November 03, 2000 3:06 PM
Subject: Dynamic Variable Names in a CFSET


> Hello,
>
> What's the best way to dynamically name variables used in a CFSET tag?
>
> I want them named choice0, choice1, etc up through however many loops are
> made:
>
>   (which does not work but illustrates what
I'm
> trying to do.
>
> Thanks,
> Dave
>
> --
--
> Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
> Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists or send
a message with 'unsubscribe' in the body to
[EMAIL PROTECTED]
>


Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists or send a message 
with 'unsubscribe' in the body to [EMAIL PROTECTED]



RE: Dynamic Variable Names in a CFSET

2000-11-02 Thread Peter Alexandrou



> -Original Message-
> From: David Hannum [mailto:[EMAIL PROTECTED]]
> Sent: Friday, 3 November 2000 15:06
> To: CF-Talk
> Subject: Dynamic Variable Names in a CFSET
> 
> 
> Hello,
> 
> What's the best way to dynamically name variables used in a CFSET tag?
> 
> I want them named choice0, choice1, etc up through however 
> many loops are
> made:
> 
>   (which does not work but 
> illustrates what I'm
> trying to do.
> 
> Thanks,
> Dave
> 
> --
> --
> Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
> Unsubscribe: 
> http://www.houseoffusion.com/index.cfm?sidebar=lists or send 
> a message with 'unsubscribe' in the body to 
> [EMAIL PROTECTED]

Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists or send a message 
with 'unsubscribe' in the body to [EMAIL PROTECTED]



RE: Dynamic Variable Names in a CFSET

2000-11-02 Thread Scott Wood

just set a loop from n to n to populate..()..  Hope that shoots you
in the rite direction..


G. Scott Wood
Developer
HMWeb.com
520-742-2611 Ext.135


-Original Message-
From: David Hannum [mailto:[EMAIL PROTECTED]]
Sent: Thursday, November 02, 2000 9:06 PM
To: CF-Talk
Subject: Dynamic Variable Names in a CFSET


Hello,

What's the best way to dynamically name variables used in a CFSET tag?

I want them named choice0, choice1, etc up through however many loops are
made:

  (which does not work but illustrates what I'm
trying to do.

Thanks,
Dave



Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists or send a
message with 'unsubscribe' in the body to [EMAIL PROTECTED]

Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists or send a message 
with 'unsubscribe' in the body to [EMAIL PROTECTED]



Re: Dynamic Variable Names in a CFSET

2000-11-02 Thread Max Paperno


Dave, you're real close.  Just do



There's also the SetVariable() function that can be used to do the same thing (check 
the docs).  I'm not sure there's much of an advantage to either way of doing it.  I 
believe the above example only works with CF4 and up, while the SetVariable function 
has been around longer.

Cheers,
-Max


At 11/2/2000 11:06 PM -0500, you wrote:
>Hello,
>
>What's the best way to dynamically name variables used in a CFSET tag?
>
>I want them named choice0, choice1, etc up through however many loops are
>made:
>
>  (which does not work but illustrates what I'm
>trying to do.
>
>Thanks,
>Dave


Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists or send a message 
with 'unsubscribe' in the body to [EMAIL PROTECTED]



RE: Dynamic Variable Names in a CFSET

2000-11-02 Thread Norman Elton

Try:



Norman Elton
Information Technology
College of William & Mary

-Original Message-
From: David Hannum [mailto:[EMAIL PROTECTED]]
Sent: Thursday, November 02, 2000 11:06 PM
To: CF-Talk
Subject: Dynamic Variable Names in a CFSET


Hello,

What's the best way to dynamically name variables used in a CFSET tag?

I want them named choice0, choice1, etc up through however many loops are
made:

  (which does not work but illustrates what I'm
trying to do.

Thanks,
Dave



Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists or send a
message with 'unsubscribe' in the body to [EMAIL PROTECTED]


Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists or send a message 
with 'unsubscribe' in the body to [EMAIL PROTECTED]



Re: Dynamic Variable Names in a CFSET

2000-11-02 Thread David Shadovitz


-David

On Thu, 2 Nov 2000 23:06:20 -0500 "David Hannum"
<[EMAIL PROTECTED]> writes:
> Hello,
> 
> What's the best way to dynamically name variables used in a CFSET 
> tag?
> 
> I want them named choice0, choice1, etc up through however many 
> loops are
> made:
> 
>   (which does not work but illustrates 
> what I'm
> trying to do.
> 
> Thanks,
> Dave

YOU'RE PAYING TOO MUCH FOR THE INTERNET!
Juno now offers FREE Internet Access!
Try it today - there's no risk!  For your FREE software, visit:
http://dl.www.juno.com/get/tagj.

Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists or send a message 
with 'unsubscribe' in the body to [EMAIL PROTECTED]



RE: Dynamic Variable Names in a CFSET

2000-11-03 Thread Kedar Desai

This code works:


-Original Message-
From: David Shadovitz [mailto:[EMAIL PROTECTED]]
Sent: Friday, November 03, 2000 12:39 AM
To: CF-Talk
Subject: Re: Dynamic Variable Names in a CFSET



-David

On Thu, 2 Nov 2000 23:06:20 -0500 "David Hannum"
<[EMAIL PROTECTED]> writes:
> Hello,
>
> What's the best way to dynamically name variables used in a CFSET
> tag?
>
> I want them named choice0, choice1, etc up through however many
> loops are
> made:
>
>   (which does not work but illustrates
> what I'm
> trying to do.
>
> Thanks,
> Dave

YOU'RE PAYING TOO MUCH FOR THE INTERNET!
Juno now offers FREE Internet Access!
Try it today - there's no risk!  For your FREE software, visit:
http://dl.www.juno.com/get/tagj.


Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists or send a
message with 'unsubscribe' in the body to [EMAIL PROTECTED]


_
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists or send a message 
with 'unsubscribe' in the body to [EMAIL PROTECTED]



RE: Dynamic Variable Names in a CFSET

2000-11-05 Thread Dave Watts

> What's the best way to dynamically name variables used in a 
> CFSET tag?
> 
> I want them named choice0, choice1, etc up through however 
> many loops are made:
> 
>   (which does not work but 
> illustrates what I'm trying to do.

As many people have already pointed out, you can do it two ways:



or



Of those two, I'd recommend the second, simply because it will be supported
in future versions of CF, while the first one may not be.

However, you might consider using a one-dimensional array instead. Rather
than "choice0", "choice1", and so on, you could create a single variable,
"choice":







This will probably perform faster, as string evaluation is generally a
relatively expensive operation. In addition, you'll get extra functionality
courtesy of the Array functions.

Dave Watts, CTO, Fig Leaf Software
http://www.figleaf.com/
voice: (202) 797-5496
fax: (202) 797-5444

Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists or send a message 
with 'unsubscribe' in the body to [EMAIL PROTECTED]



Re: Dynamic Variable Names in a CFSET

2000-11-05 Thread Jon Hall

Does rs have any special meaning or does it not matter?

jon
>
> 
>
> Of those two, I'd recommend the second, simply because it will be
supported
> in future versions of CF, while the first one may not be.
>
> However, you might consider using a one-dimensional array instead. Rather
> than "choice0", "choice1", and so on, you could create a single variable,
> "choice":
>
> 
>
> 
> 
> 
>
> This will probably perform faster, as string evaluation is generally a
> relatively expensive operation. In addition, you'll get extra
functionality
> courtesy of the Array functions.
>
> Dave Watts, CTO, Fig Leaf Software
> http://www.figleaf.com/
> voice: (202) 797-5496
> fax: (202) 797-5444
> --
--
> Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
> Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists or send
a message with 'unsubscribe' in the body to
[EMAIL PROTECTED]


Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists or send a message 
with 'unsubscribe' in the body to [EMAIL PROTECTED]



RE: Dynamic Variable Names in a CFSET

2000-11-06 Thread Dave Watts

> > 
>
> Does rs have any special meaning or does it not matter?

No, it's a dummy variable. It stands for "return string". In fact, as has
been pointed out before, you could omit the left side of the CFSET, and it
would still work:



Again, though, I'd recommend not doing that, since there's no guarantee that
this behavior will be supported in future versions of CF.

Dave Watts, CTO, Fig Leaf Software
http://www.figleaf.com/
voice: (202) 797-5496
fax: (202) 797-5444

Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists or send a message 
with 'unsubscribe' in the body to [EMAIL PROTECTED]