Here are some tips:

Basically there are two ways that came to my mind to solve your problem,

One would be using Array (let's also assume that your form variables are
stored in var. names as form.myVar_1,form.myVar_2,form.myVar_3 ...
form.myVar_10):

<CFSET Session.Variable = ArrayNew(1)>
<CFLOOP From="1" To="10" Index="ndx">
        <CFSET Session.Variable[variables.ndx] =
Evaluate("form.myVar_#variables.ndx#")>
</CFLOOP>

<CFLOOP From="1" To="10" Index="ndx">
        <CFOUTPUT>#Session.Variable[variables.ndx]#</CFOUTPUT>
</CFLOOP>


Another is using Structure:

<CFSET Session.Variable = StructNew()>
<CFLOOP From="1" To="10" Index="ndx">
        <CFSET Session.Variable[variables.ndx] =
Evaluate("form.myVar_#variables.ndx#")>
</CFLOOP>

<CFLOOP From="1" To="10" Index="ndx">
        <CFOUTPUT>#Session.Variable[variables.ndx]#</CFOUTPUT>
</CFLOOP>


Please remember the major differences between the arrays and structures.

Also I don't know of any possibility using variables on left side on
assigment (<CFSET Session.Variable_#ndx# = Form.FormField>) other then
mentioned about. However if there is variable set already it's possible to
read from it. Look at the following example:

<CFSET Session.Variable_1 = "xxx">
<CFSET Session.Variable_2 = "yyy">
<CFSET Session.Variable_3 = "zzz">

<CFLOOP From="1" To="3" Index="ndx">
        <CFOUTPUT>#Evaluate("Session.Variable_#variables.ndx#")#</CFOUTPUT>
</CFLOOP>

This would work also however you'll be limited to values hard coded in your
code (not dynamic) and also lose ability to use nice scale of functions that
using of arrays and/or structures would give you.

If you have additional questions feel free to ask.


Rastislav Toscak
Senior Applications Developer
Computer Horizons Corp.
Tel : 973.884.5228
Fax : 973.884.5342
[EMAIL PROTECTED]
http://www.computerhorizons.com


-----Original Message-----
From: Herman Cremer [mailto:[EMAIL PROTECTED]]
Sent: Thursday, October 25, 2001 8:56 AM
To: CF-Server
Subject: Variables


'elo list.

I wonder if anyone can help.

I am trying to set up 10 session variables.
Like so:

<CFLOOP From="1" To="10" Index="ndx">
        <CFSET Session.Variable_#ndx# = Form.FormField>
</CFLOOP>


And then display them.
like so:
<CFLOOP From="1" To="10" Index="ndx">
        #Session.Variable_#ndx##
</CFLOOP>

This code does not work, but its just to give you an idea of what I am
trying to do.
My question...Can one use on variable as part of another ?!?! -if this makes
sense.-

Another example:
Is this possible ?

<CFSET x = "var1">
<CFSET MyVar#var1# = "a value">


Any suggestions welcome.

Herman Cremer
South Africa.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Get the mailserver that powers this list at http://www.coolfusion.com
------------------------------------------------------------------------------
To unsubscribe, send a message to [EMAIL PROTECTED] with 
'unsubscribe' in the body or visit the list page at www.houseoffusion.com

Reply via email to