What am i doing wrong here:
I am building a shopping cart everything with this code works ok if I change
the qty it updates correctly.
The trouble begins when i try adding a new Item.
When I do this it overwrites the old entry completely.

Thanks and HAPPY NEW YEAR
Rick

<cfparam name="form.ProductID" default="">
<cfparam name="form.ProductClass" default="">
<cfparam name="form.GroupID" default="">
<cfparam name="form.ProductName" default="">
<cfparam name="form.Price" default="">
<cfparam name="form.Quantity" default="">

<cfset basket = StructNew()>

<cfoutput>
   <cfscript>
// if its not there add it...
   if (not(StructKeyExists(basket, "#form.ProductID#"))){
      StructInsert(basket, "id", "#form.ProductID#");
      StructInsert(basket, "class", "#form.ProductClass#");
      StructInsert(basket, "Group", "#form.GroupID#");
      StructInsert(basket, "name", "#form.ProductName#");
      StructInsert(basket, "cost", "#form.Price#");
      StructInsert(basket, "Qty", "#form.Quantity#");

   }
   else {
// if there is a change in qty change it
      StructUpdate(basket, "Qty", "#form.Quantity#");
  }
   </cfscript>
</cfoutput>

<cfoutput>
<P>#StructFind(basket, "id")#</P>
  <P>#StructFind(basket, "class")#</P>
  <P>#StructFind(basket, "Group")#</P>
  <P>#StructFind(basket, "name")#</P>
  <P>#StructFind(basket, "cost")#</P>
  <p>#StructFind(basket, "Qty")#,</p>
</cfoutput>


~~~~~~~~~~~~~ Paid Sponsorship ~~~~~~~~~~~~~
Get Your Own Dedicated Win2K Server!      Instant Activation for $99/month w/Free 
Setup from SoloServer      PIII600 / 128 MB RAM / 20 GB HD / 24/7/365 Tech Support     
 Visit SoloServer, https://secure.irides.com/clientsetup.cfm.

Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to