home *** CD-ROM | disk | FTP | other *** search
/ Australian Personal Computer 1999 April / APC443.iso / features / grpware / coldfus / coldfusi.exe / data1.cab / Examples / store / additem.cfm < prev    next >
Encoding:
Text File  |  1998-10-08  |  1.7 KB  |  58 lines

  1. <!--- This template adds a specified quantity of a certain item to the
  2.       shopping cart.  The item is indicated by Form.ItemID and the quantity
  3.       to be added is indicated by Form.Quant --->
  4.  
  5. <!--- Begin code that actually adds the item --->
  6.  
  7.     <!--- If the item is already in the basket... --->
  8.     <CFIF ListFind(Session.StoreItems, Form.ItemID) NEQ 0>
  9.     
  10.         <!--- Find where in the basket it is --->
  11.         <CFSET ItemPosition = ListFind(Session.StoreItems, Form.ItemID)>
  12.         <!--- Find out how many of the item are already in the basket --->
  13.         <CFSET CurrentQuantity = ListGetAt(Session.StoreQuantities, ItemPosition)>
  14.         <!--- Now we add one to what's already in there --->
  15.         <CFSET Session.StoreQuantities = ListSetAt(Session.StoreQuantities, ItemPosition, CurrentQuantity + 1)>
  16.     
  17.     <!--- Otherwise, just add it to the basket --->
  18.     <CFELSE>
  19.     
  20.         <CFSET Session.StoreItems = ListAppend(Session.StoreItems, Form.ItemID)>
  21.         <CFSET Session.StoreQuantities = ListAppend(Session.StoreQuantities, 1)>
  22.     
  23.     </CFIF>
  24.  
  25. <!--- End code that adds the item --->
  26.  
  27. <CFQUERY DATASOURCE="CFexamples" NAME="GetItem">
  28.     SELECT ItemName FROM StoreItems
  29.     WHERE ItemID = #Form.ItemID#
  30. </CFQUERY>
  31.  
  32. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
  33.  
  34. <HTML>
  35. <HEAD>
  36.     <TITLE>Online Store - Shopping Cart</TITLE>
  37. </HEAD>
  38.  
  39. <BODY BGCOLOR="#FFCC00" LINK="Maroon" background="images/storebg.gif" leftmargin=5 topmargin=0>
  40.  
  41.  
  42. <CFOUTPUT QUERY="GetItem">
  43.     <SCRIPT LANGUAGE="JAVASCRIPT">
  44.     alert('A(n) #ItemName# was added to your shopping cart.')
  45.     </SCRIPT>
  46. </CFOUTPUT>
  47.  
  48. <SPAN STYLE="position: absolute; left: 205px; top: 15px; width: 350px;">
  49.     <CFINCLUDE TEMPLATE="_showitems.cfm">
  50.     <BR><BR>
  51.     <CF_ShowDoc ID=3>
  52. </SPAN>
  53.  
  54. <CFINCLUDE TEMPLATE="_showcart.cfm">
  55.  
  56. </BODY>
  57. </HTML>
  58.