home *** CD-ROM | disk | FTP | other *** search
- <!--- This template adds a specified quantity of a certain item to the
- shopping cart. The item is indicated by Form.ItemID and the quantity
- to be added is indicated by Form.Quant --->
-
- <!--- Begin code that actually adds the item --->
-
- <!--- If the item is already in the basket... --->
- <CFIF ListFind(Session.StoreItems, Form.ItemID) NEQ 0>
-
- <!--- Find where in the basket it is --->
- <CFSET ItemPosition = ListFind(Session.StoreItems, Form.ItemID)>
- <!--- Find out how many of the item are already in the basket --->
- <CFSET CurrentQuantity = ListGetAt(Session.StoreQuantities, ItemPosition)>
- <!--- Now we add one to what's already in there --->
- <CFSET Session.StoreQuantities = ListSetAt(Session.StoreQuantities, ItemPosition, CurrentQuantity + 1)>
-
- <!--- Otherwise, just add it to the basket --->
- <CFELSE>
-
- <CFSET Session.StoreItems = ListAppend(Session.StoreItems, Form.ItemID)>
- <CFSET Session.StoreQuantities = ListAppend(Session.StoreQuantities, 1)>
-
- </CFIF>
-
- <!--- End code that adds the item --->
-
- <CFQUERY DATASOURCE="CFexamples" NAME="GetItem">
- SELECT ItemName FROM StoreItems
- WHERE ItemID = #Form.ItemID#
- </CFQUERY>
-
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
-
- <HTML>
- <HEAD>
- <TITLE>Online Store - Shopping Cart</TITLE>
- </HEAD>
-
- <BODY BGCOLOR="#FFCC00" LINK="Maroon" background="images/storebg.gif" leftmargin=5 topmargin=0>
-
-
- <CFOUTPUT QUERY="GetItem">
- <SCRIPT LANGUAGE="JAVASCRIPT">
- alert('A(n) #ItemName# was added to your shopping cart.')
- </SCRIPT>
- </CFOUTPUT>
-
- <SPAN STYLE="position: absolute; left: 205px; top: 15px; width: 350px;">
- <CFINCLUDE TEMPLATE="_showitems.cfm">
- <BR><BR>
- <CF_ShowDoc ID=3>
- </SPAN>
-
- <CFINCLUDE TEMPLATE="_showcart.cfm">
-
- </BODY>
- </HTML>
-