- <html>
- <head>
- <style type="text/css">
- TR {
- border: 1px solid #C0C0C0; height: 20px; color: blue; font-size: 14; font-family: arial;
- }
- TD {
- border: 1px solid #C0C0C0; width: 200px; height: 50px; color: blue; font-size: 12; font-family: arial;
- }
- P {
- font-size: 12; font-family: arial; color: blue;
- }
- a:visited {color: blue}
- </style>
- </head>
- <body>
- <%
- Sub AddItemToCart(iItemID, iItemCount)
- If dictCart.Exists(iItemID) Then
- dictCart(iItemID) = dictCart(iItemID) + iItemCount
- Else
- dictCart.Add iItemID, iItemCount
- End If
- End Sub
- Sub ShowItemsInCart()
- Dim Key
- Dim aParameters
- Dim sTotal
- %>
- <TABLE Border=1 CellPadding=3 CellSpacing=1>
- <TR>
- <TD>Product</TD>
- <TD>Beschrijving</TD>
- <TD>Aantal</TD>
- <TD>Prijs</TD>
- <TD>Totaal</TD>
- </TR>
- <%
- sTotal = 0
- For Each Key in dictCart
- aParameters = GetItemParameters(Key)
- %>
- <TR>
- <TD ALIGN="Center"><%= Key %></TD>
- <TD ALIGN="Left"><%= aParameters(1) %></TD>
- <TD ALIGN="Center"><%= dictCart(Key) %></TD>
- <TD ALIGN="Right">$<%= aParameters(2) %></TD>
- <TD ALIGN="Right">$<%= FormatNumber(dictCart(Key) * CSng(aParameters(2)),2) %></TD>
- </TR>
- <%
- sTotal = sTotal + (dictCart(Key) * CSng(aParameters(2)))
- Next
- %>
- <TR><TD COLSPAN=4 ALIGN="Right"><B>Totaal:</B></TD><TD ALIGN="Right">$<%= FormatNumber(sTotal,2) %></TD></TR>
- </TABLE>
- <%
- End Sub
- Sub ShowFullCatalog()
- Dim aParameters
- Dim I
- Dim iItemCount
- iItemCount = 3
- %>
- <TABLE Border=1 CellPadding=3 CellSpacing=1>
- <TR>
- <TD>Afbeelding</TD>
- <TD>Beschrijving</TD>
- <TD>Prijs</TD>
- <TD> </TD>
- </TR>
- <%
- For I = 1 to iItemCount
- aParameters = GetItemParameters(I)
- %>
- <TR>
- <TD><IMG SRC="<%= aParameters(0) %>" width=100 height=100></TD>
- <TD><%= aParameters(1) %></TD>
- <TD>€<%= aParameters(2) %></TD>
- <TD><A HREF="./test.asp?action=add&item=<%= I %>&count=1"><img src="winkelmandje.gif" border=0>toevoegen</A></TD>
- </TR>
- <%
- Next
- %>
- </TABLE>
- <%
- End Sub
- Function GetItemParameters(iItemID)
- Dim aParameters
- Select Case iItemID
- Case 1
- aParameters = Array("1.jpg", "Met deze Octopus kun je masseren. Exclusief 2 AA batterijen.", "6.50")
- Case 2
- aParameters = Array("2.jpg", "Baden met deze badeend die een radio is. Het is waterdicht.", "24.50")
- Case 3
- aParameters = Array("3.jpg", "Knuffels die levensecht snurken. Inclusief batterijen.", "13.50")
- Case 4 ' Not in use because we couldn't draw a pen in a few seconds!
- aParameters = Array("./images/shop_pen.gif", "ASP 101 Pen", "5.00")
- End Select
- ' Return array containing product info.
- GetItemParameters = aParameters
- End Function
- Dim dictCart ' as dictionary
- Dim sAction ' as string
- Dim iItemID ' as integer
- Dim iItemCount ' as integer
- ' Get a reference to the cart if it exists otherwise create it
- If IsObject(Session("cart")) Then
- Set dictCart = Session("cart")
- Else
- ' We use a dictionary so we can name our keys to correspond to our
- ' item numbers and then use their value to hold the quantity. An
- ' array would also work, but would be a little more complex and
- ' probably not as easy for readers to follow.
- Set dictCart = Server.CreateObject("Scripting.Dictionary")
- End If
- ' Get all the parameters passed to the script
- sAction = CStr(Request.QueryString("action"))
- iItemID = CInt(Request.QueryString("item"))
- iItemCount = CInt(Request.QueryString("count"))
- %>
- <TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0>
- <TR><TD>
- <%
- Select Case sAction
- Case "add"
- AddItemToCart iItemID, iItemCount
- ShowItemsInCart
- %>
- </TD></TR>
- </TR>
- <TR><TD ALIGN="right">
- <A HREF="./test.asp?action="><IMG SRC="./images/shop_look.gif" BORDER=0 WIDTH=46 HEIGHT=46></A>
- <%
- Case "viewcart"
- ShowItemsInCart
- %>
- </TD></TR>
- <%
- Case Else
- ShowFullCatalog
- %>
- </TD></TR>
- <TR><TD ALIGN="left">
- <A HREF="./test.asp?action=viewcart">Winkelwagen<IMG SRC="winkelmandje.gif" BORDER=0></A>
- <%
- End Select
- ' Return cart to Session for storage
- Set Session("cart") = dictCart
- %>
- </TD></TR>
- </TABLE>
- </body>
- </html>
asp
By: anoniem | Date: Nov 18 2006 14:42 | Format: None | Expires: never | Size: 4.54 KB | Hits: 1563
Latest pastes
1 hours ago
11 hours ago
1 days ago
2 days ago
2 days ago