<% Option Explicit %> <% dim AlbumNo : AlbumNo = getAlbumNo(Request.form) if AddToCart(AlbumNo) = False then Response.redirect "viewcart.asp" ' redirects if AlbumNo is already in the cart %> Untitled Document <% DisplayHeader "Shop" DisplayNavMenu "Shop" %>
<% Main %>
<% sub Main() dim rs dim albumNumbers, quantities, i dim subTotal Response.write "" & _ "You have added to your shopping cart:" & _ "Quantity" & _ "" & _ " " albumNumbers = GetCartItems() quantities = GetCartQuantities() set rs = GetAlbumsInfo(albumNumbers) rs.filter = "AlbumNo=" & AlbumNo subTotal = rs("OurPrice") displayAlbumInfo rs, 1 Response.write " " ' if there is more than one album in the cart if ubound(albumNumbers) > 0 then Response.write "
" & _ "Your shopping cart also contains:" & _ " " ' displays albums (except the newly added album) in the order albums were chosen by user for i = 0 to ubound(albumNumbers) - 1 rs.filter = adFilterNone rs.filter = "AlbumNo=" & albumNumbers(i) subTotal = subTotal + (quantities(i) * rs("OurPrice")) displayAlbumInfo rs, quantities(i) Response.write " " next end if rs.close set rs = Nothing Response.write "
" & _ "Subtotal: " & formatCurrency(subTotal) & "" & _ " " end sub %> <% sub displayAlbumInfo(rs, quantity) %> ">" border="0"> " style="font-style: italic"><%= rs("AlbumTitle") %>
"><%= rs("ArtistName") %>
Item #<%= rs("AlbumNo") %>
<%= formatCurrency(rs("OurPrice")) %> " size="2" maxlength="4" value="<%= quantity %>"> " src="images/buttons/remove.gif">
<% end sub %> <% ' req is Request.form function getAlbumNo(req) dim field for each field in req if inStr(field, "Add") then getAlbumNo = ExtractAlbumNoFromString(field) exit function end if next end function %>