p = 0
for each i in request.Form("chk_remove")
k = i - p
for j = (k+1) to session("item")
cart(0 , j-1) = cart(0 , j)
cart(1 , j-1) = cart(1 , j)
cart(2, j-1) = cart(2 , j)
cart(3 , j-1) = cart(3 , j)
function add(id,name,price,qty)
'เพิ่ม
'''''''''''''''''''''''''''''''''''
bool_add = true
for i = 1 to session("item")
if id = cart(0,i) then 'check product
bool_add = false
cart(3,i) = cart(3,i) + int(qty)
exit for
end if
next
'----------------------------
if bool_add then
session("item") = session("item") +1
redim preserve cart(3,session("item"))
cart(0,session("item")) =id
cart(1,session("item")) =name
cart(2,session("item")) =price
cart(3,session("item")) =qty
end if
add = cart
'----------------------------
end function
if not isempty(request.Form("product")) then
for each product in request.Form("product")
arr = split( product , "," )
session("cart")=add( arr(0),arr(1),arr(2),arr(3) )
next
response.Redirect("cart.asp")
end if
if not isempty(request.Form("recal")) then
'----------------------------------------
for i=1to session("item")
if not isNumeric (request.Form("txt_qty")(i) ) then
response.Write("<script>alert('ตัวเลข');window.location='cart.asp'</script>")
response.End()
elseif request.Form("txt_qty")(i) < "1" then
response.Write("<script>alert('<<<<<< 1');window.location='cart.asp'</script>")
response.End()
else
cart(3,i) = request.Form("txt_qty")(i)'ใช้ระบุตำเเหน่ง .ในกรณีที่ ชื่อเหมือนกาน
end if
next
'update--------------------
p = 0
for each i in request.Form("chk_remove")
k = i - p
for j = (k+1) to session("item")
cart(0 , j-1) = cart(0 , j)
cart(1 , j-1) = cart(1 , j)
cart(2, j-1) = cart(2 , j)
cart(3 , j-1) = cart(3 , j)
Q = 0
S = 0
for i = 1 to session("item")
Q =Q + int(cart(3,i))
S =S + (cart(3,i)*cart(2,i))
%>
<tr>
<td><div align="center">
<input type="checkbox" name="chk_remove" value="<%=i%>">
</div></td>
<td><img src="image/<%=cart(0,i)%>.jpg"><br><%=cart(1,i)%></td>
<td><div align="center"><%=cart(2,i)%></div></td>
<td>
<div align="right">
<input name="txt_qty" value="<%=cart(3,i)%>" type="text" size="5" maxlength="5">
</div></td><td><div align="right"><%=cart(3,i)*cart(2,i)%></div></td>
</tr>
<%next
if S >=50000 then
session("shipping") = 0
elseif S >= 10000 and S <= 49999 then
session("shipping") = S*0.01 'เปง %
elseif S >= 1000 and S <= 4999 then
session("shipping") = S*0.5
else
session("shipping") = S*0.10
end if