ro6er
Programmer
- Jul 1, 2003
- 76
It's probably something simple but for some reason the quanity isn't being added from this page:
to :
index.asp has the following code:
<input type="text" name="qty" value="1" size="1">
<input type="hidden" name="dir" value="<%=rsBuckles("price")%>">
<input type="image" src="images/add_basket.gif" border=0 alt="Buy">
cart.asp has this:
<%
session.lcid=2057
Session.Timeout=50
if not isObject(Session("cart")) then
set Session("cart")=Server.CreateObject("Scripting.Dictionary")
end if
add=Request("add")
qty=Request("qty")
del=Request("del")
price=Request("dir")
if add<>"" then
'check if data is no there
if not Session("cart").Exists(add) then 'add to cart
'get data from database this example is without
set recData=Server.CreateObject("Scripting.Dictionary")
recData.Add "cart_no",add
recData.Add "qty",1
recData.Add "price",price
'store the cart to it's cart_no
Session("cart").Add add,recData
else 'flight_id exists
'add only the qty
Session("cart")(add)("qty")=Session("cart")(add)("qty")+CInt(qty)
end if
end if
if del<>"" then
'remove from cart
Session("cart").Remove(del)
end if
'store back to session object
'here display your cart
if IsObject(Session("cart")) then
if Session("cart").Count>0 then
cartItems=Session("cart").Items
For i=Lbound(cartItems) to Ubound(cartItems)
cart_no=cartItems(i)("cart_no")
price=cartItems(i)("price")
qty=cartItems(i)("qty")
'calculate total
orderTotal = orderTotal + cartItems(i)("price") * cartItems(i)("qty")
Response.Write "<td><a href=""cart.asp?del="&cart_no&"""><img src=""images/delete.gif"" border=0></a></td>"
Response.Write "<td>"&(i+1)& ": "&cart_no&" </td><td><b>£"&price&" </b></td><br /></tr>"
Response.Write "<td></td><td>Quanity: "&qty&"</td></tr>"
Next
Response.Write "<td><br /><br /></td><td><b>Total</b></td><td><b>"
'print total
Response.Write formatCurrency( orderTotal )
Response.Write "</b></td>"
Response.Write "</table><div align=""center""><br /><br /><a href=""login.asp""><img src=""images/checkout.gif"" border=0></a></div>"
else
Response.Write ("<td><br /><br /></td><td><b>Your shopping cart is empty</td><td><b>")
end if
end if
%>
Thanks for any help, Roger
to :
index.asp has the following code:
<input type="text" name="qty" value="1" size="1">
<input type="hidden" name="dir" value="<%=rsBuckles("price")%>">
<input type="image" src="images/add_basket.gif" border=0 alt="Buy">
cart.asp has this:
<%
session.lcid=2057
Session.Timeout=50
if not isObject(Session("cart")) then
set Session("cart")=Server.CreateObject("Scripting.Dictionary")
end if
add=Request("add")
qty=Request("qty")
del=Request("del")
price=Request("dir")
if add<>"" then
'check if data is no there
if not Session("cart").Exists(add) then 'add to cart
'get data from database this example is without
set recData=Server.CreateObject("Scripting.Dictionary")
recData.Add "cart_no",add
recData.Add "qty",1
recData.Add "price",price
'store the cart to it's cart_no
Session("cart").Add add,recData
else 'flight_id exists
'add only the qty
Session("cart")(add)("qty")=Session("cart")(add)("qty")+CInt(qty)
end if
end if
if del<>"" then
'remove from cart
Session("cart").Remove(del)
end if
'store back to session object
'here display your cart
if IsObject(Session("cart")) then
if Session("cart").Count>0 then
cartItems=Session("cart").Items
For i=Lbound(cartItems) to Ubound(cartItems)
cart_no=cartItems(i)("cart_no")
price=cartItems(i)("price")
qty=cartItems(i)("qty")
'calculate total
orderTotal = orderTotal + cartItems(i)("price") * cartItems(i)("qty")
Response.Write "<td><a href=""cart.asp?del="&cart_no&"""><img src=""images/delete.gif"" border=0></a></td>"
Response.Write "<td>"&(i+1)& ": "&cart_no&" </td><td><b>£"&price&" </b></td><br /></tr>"
Response.Write "<td></td><td>Quanity: "&qty&"</td></tr>"
Next
Response.Write "<td><br /><br /></td><td><b>Total</b></td><td><b>"
'print total
Response.Write formatCurrency( orderTotal )
Response.Write "</b></td>"
Response.Write "</table><div align=""center""><br /><br /><a href=""login.asp""><img src=""images/checkout.gif"" border=0></a></div>"
else
Response.Write ("<td><br /><br /></td><td><b>Your shopping cart is empty</td><td><b>")
end if
end if
%>
Thanks for any help, Roger