What is the value of "id" in your query result set?
The way you've got the CFIF condition set up, unless 
the value of id is literally the string "Client.lr1" 
then "Client.lr2" etc. The CFIF statement will always 
evaluate to false. 

If you're trying to compare "id" with client scoped 
variables named "lr1", "lr2" etc. Then try using the 
EVALUATE function. 

<CFSET LeftLoop = #GetLRCount.LRNumber#>

<CFLOOP INDEX="i" FROM="1" TO="#LeftLoop#">

        <CFSET numvar = i>
        <CFSET ThisVar = "Client.lr#numvar#">

        <cfoutput>
                <select name="lr#i#">
        </cfoutput>
        <cfoutput query="GetChoices">
                <option value="#id#" 
                <cfif id is Evaluate(ThisVar)>SELECTED</cfif>>
                #ChoiceName#</option>
        </cfoutput>
        </select>

-----Original Message-----
From: S R [mailto:[EMAIL PROTECTED]]
Sent: Monday, December 11, 2000 4:59 PM
To: CF-Talk
Subject: LOOP AND VARIABLE QUESTION


I have this loop below pulling from a database. As you can see, the <select>

part of the loop does exactly what I want it to. It dynamically creates lr1,

lr2, lr3, lr4, lr5, etc. The problem I am now having is where the <CFIF> 
statement is. I need that to do exactly what the <CFIF> statement is telling

it to do but it does not. Right now, each module automatically defaults to 
choice 1 because the #id# and/or #ThisVar# variable is not being fed to the 
CFIF statement. How can I accomplish this??

Sal

<CFSTOREDPROC datasource="#application.Datasource#" dbname="UserPreferences"

procedure="GetChoices">
<cfprocresult name="GetChoices">
</CFSTOREDPROC>

<CFSTOREDPROC DATASOURCE="#application.datasource#" DBNAME="UserPreferences"

PROCEDURE="sp_GetLRCount">
<CFPROCRESULT NAME="GetLRCount">
</CFSTOREDPROC>

<CFSET LeftLoop = #GetLRCount.LRNumber#>

<CFLOOP INDEX="i" FROM="1" TO="#LeftLoop#">

<CFSET numvar = i>
<CFSET ThisVar = "Client.lr#numvar#">

<cfoutput><select name="lr#i#"></cfoutput>
<cfoutput query="GetChoices">


<option value="#id#" <cfif #id# is 
#ThisVar#>SELECTED</CFIF>>#ChoiceName#</option>
</cfoutput>
</select>

<p>

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