House of Fusion
Search over 2,500 ColdFusion resources here
  
Home of the ColdFusion Community

Mailing Lists
Home /  Groups /  ColdFusion Talk (CF-Talk)

Array question

  << Previous Post |  RSS |  Sort Oldest First |  Sort Latest First |  Subscribe to this Group Next >> 
Top  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Robert Orlini
05/17/2004 03:37 PM

Why can't I get a display of the fields I'm entering with this array? When I cfoutput the #arraylen(session.item)#  its always 0 (zero). <CFIF Not IsDefined("Session.item")> <CFSET session.item = arraynew(2)> </CFIF> <CFIF isDefined("form.more.x")> <CFSET itemcount = arraylen(session.item)> #arraylen(session.item)# <CFLOOP from="1" to="#arraylen(session.item)#" index="i" step="1"> <CFSET Session.item[itemcount+1][1]=form.qty> <CFSET Session.item[itemcount+1][2]=form.item> <CFSET Session.item[itemcount+1][3]=form.priceeach> #session.item[i][1]#<br> #session.item[i][2]#<br> #session.item[i][3]#<br> </cfloop> </cfif> </CFOUTPUT> Robert Orlini HW Wilson 718-588-8400 x2656 ô¿ô

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Bryan F. Hogan
05/17/2004 03:55 PM

Because arrayLen(session.item) is 0 and your looping from 1-arrayLen(session.item). If your just trying to add an item to the array from a form post just use the following. <cfif not isDefined('session.item')>   <cfset session.item=arrayNew(2)> </cfif> <cfset arrayLength=arrayLen(session.item)> <cfset session.item[variables.arrayLength+1][1]='qty'> <cfset session.item[variables.arrayLength+1][2]='item'> <cfset session.item[variables.arrayLength+1][3]='price'> <cfoutput>#arrayLen(session.item)#</cfoutput> <cfdump var="#session.item#">

Top  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Robert Orlini
05/17/2004 04:12 PM

Thank you. One more ?: How do I clear the array to start over? Because arrayLen(session.item) is 0 and your looping from 1-arrayLen(session.item). If your just trying to add an item to the array from a form post just use the following. <cfif not isDefined('session.item')> <cfset session.item=arrayNew(2)> </cfif> <cfset arrayLength=arrayLen(session.item)> <cfset session.item[variables.arrayLength+1][1]='qty'> <cfset session.item[variables.arrayLength+1][2]='item'> <cfset session.item[variables.arrayLength+1][3]='price'> <cfoutput>#arrayLen(session.item)#</cfoutput> <cfdump var="#session.item#">   _____  

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Bryan F. Hogan
05/17/2004 04:22 PM

Use arrayClear(session.item) or just reset the array <cfset session.item=arrayNew(2)> Robert Orlini wrote: > Thank you. One more ?: How do I clear the array to start over?


<< Previous Thread Today's Threads Next Thread >>

Search cf-talk

September 06, 2010

<<   <   Today   >   >>
Su Mo Tu We Th Fr Sa
       1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30