Yes. But you also exited the program at the end of the first loop.
-----Original Message-----
From: Ben Densmore [mailto:[EMAIL PROTECTED]
Sent: Wednesday, October 01, 2003 3:42 PM
To: CF-Talk
Subject: RE: CFC Question
I don't follow completely. If I set a variable inside the loop to
contain the structure then try to return that I get the same result.
Ben
-----Original Message-----
From: Aunger, Mitch [mailto:[EMAIL PROTECTED]
Sent: Wednesday, October 01, 2003 4:36 PM
To: CF-Talk
Subject: RE: CFC Question
With a CFC, you only 'return' once... you don't return within a loop...
(in your case you are only getting the last item)
what you want to do is build a structure of names and then outside the
loop, return the structure.
make sense?
Mitch
Shameless plug for my wife's business:
http://www.mygccandle.com/showmescents
-----Original Message-----
From: Ben Densmore [mailto:[EMAIL PROTECTED]
Sent: Wednesday, October 01, 2003 3:19 PM
To: CF-Talk
Subject: CFC Question
I'm just starting to play with CFC's to get familiar with them and was
trying to write some play code to see if it would work. I got it to work
but it only displays 1 record out of a loop I'm doing. How would I go
about getting all records to display? Here is the code I'm playing with:
CFC:
<cfcomponent displayName="showArray">
<cffunction access="public" name="categories" output="false"
returntype="string">
<cfscript>
value = listToArray('Amplifiers,Mixers,Modulators,Switches');
session.cart = structNew();
structInsert(session.cart, "Product Category", "#value#");
</cfscript>
<cfloop collection="#session.cart#" item="i">
<cfloop from="1" to="#Arraylen(value)#" index="j">
<cfset names = "#i# #j#: #session.cart[i][j]#">
<cfreturn names />
</cfloop>
</cfloop>
</cffunction>
</cfcomponent>
cfm File:
<cfinvoke
component="category"
method="categories"
returnvariable="var">
</cfinvoke>
<cfoutput>#var#</cfoutput><br>
so instead of showing 4 values I get Product Name 1: Amplifiers, how do
I get all 4 to display as they would if I had all my code inline in a
cfm page?
Thanks,
Ben
_____
[Todays
_____
[Todays Threads]
[This Message]
[Subscription]
[Fast Unsubscribe]
[User Settings]
- RE: CFC question Andy Ousterhout
- CFC question Douglas.Knudsen
- RE: CFC question Mike Townend
- RE: CFC question Raymond Camden
- Re: CFC question Kwang Suh
- RE: CFC question Douglas.Knudsen
- CFC Question Ben Densmore
- RE: CFC Question Andy Ousterhout
- RE: CFC Question Aunger, Mitch
- RE: CFC Question Ben Densmore
- RE: CFC Question Andy Ousterhout
- RE: CFC Question Barney Boisvert
- CFC question John McCosker
- RE: CFC question Raymond Camden
- RE: CFC question John McCosker
- RE: CFC question Raymond Camden
- cfc question Tony Weeg
- Re: cfc question Tony Weeg
- RE: cfc question Jim Davis