Claude

 

1)      ArrayNew() takes 1 argument being the dimension of the array so you
need to say ArrayNew(1)

2)      You are setting session.cart to the string of "arrayNew()" so you
cant append the cart item because arrayNew(0 is a string, not an array so
you need

<cfparam name="session.cart", default="#Arraynew(1)# />

3)      If your cart item keys are the same as your form fields you can just
do
<cfset arrayAppend(session.cart, duplicate(FORM)) />

Just saves on code but if you  have lots of fields in your form you don't
need then maybe setting them manually as you have done may be better.

 

 

Steve

 

From: rai...@ozemail.com.au [mailto:rai...@ozemail.com.au] 
Sent: Monday, 21 June 2010 11:40 PM
To: cfaussie@googlegroups.com; coldfusion-ho...@yahoogroups.com
Subject: [cfaussie] Trying To Create A Basic Shopping Cart

 

Hi

 

I am trying my hand at a basic shopping cart

 

I have found an example online that uses the following code

 

<cfparam name="session.cart" default="arrayNew()">

<cfset session.cart = arrayAppend( session.cart, structNew() )>

<cfset thisCartItem = arraylen( session.cart )>

<cfset session.cart[thisCartItem].itemID = form.itemID>

<cfset session.cart[thisCartItem].quantity = form.quantity>

<cfset session.cart[thisCartItem].itemName = form.itemName>

 

 

However the code generates the following error message:

 

Object of type class java.lang.String cannot be used as an array 

 

 

If someone would like to advise where the above code is causing the error
message I would be grateful

Regards

Claude Raiola (B.Econ Acc; B.Hot. Mngt)
Samaris Software
Email: i...@samaris.net <mailto:i...@trackingcentral.om.au> 
Website: www.SAMARIS.net <http://www.TrackingCentral.com.au> 
Mobile: 0414 228 948

 

-- 
You received this message because you are subscribed to the Google Groups
"cfaussie" group.
To post to this group, send email to cfaus...@googlegroups.com.
To unsubscribe from this group, send email to
cfaussie+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/cfaussie?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"cfaussie" group.
To post to this group, send email to cfaus...@googlegroups.com.
To unsubscribe from this group, send email to 
cfaussie+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/cfaussie?hl=en.

Reply via email to