That's because The return command sends you back to the calling program.  Why
not just return session.cart at the end of your script and deleted the
imbedded loops.

Andy
  -----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 Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to