⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cartbase.asp

📁 网上购物源代码
💻 ASP
字号:
<%

Sub PutToCart( productID,quantity)
   dim productList, quantityList
   '放到本地变量中,以期提高效率
   productList = Session("productList")
   quantityList = Session("quantityList")
   
   If Len(productList)  =  0 Then
      Session("productList")  = productID 
	  Session("quantityList") = quantity 
   ElseIf InStr( productList & ",",  productID & "," ) <=  0 Then
      Session("productList")  =   productID & ", " & productList
      Session("quantityList")  =  quantity  & ", " & quantityList
   End If
End Sub


sub ShowCart()
	dim canPay
%>
<style type="text/css">
<!--
.style1 {color: #000000}
-->
</style>

<table width = "100%" border = "0" cellspacing = "0" ID = "Table1" height="290">
	<TR>
		<TD class  = "tabTitle" height = "22"  bgColor=<%=conTitleColor%>><b>Shoppinglist</b></TD>
	</TR>
	<TR>
  <tr>
    <td width = "80%" valign = "top"><p align = "center">
		<font color = "#FF0000" class = main1><%=Head%></font>
		<form name = "form1" Action = "shopCart.asp" Method = "POST" ID = "Form1">
			<input type = "hidden" name = "Modify" value = "Yes" ID = "Hidden1">
			<div align = "center">
<%	
			canPay  =  ShowCartTable()
%>
			<blockquote>
				<p align = "center">
				<input Type = "submit" Value = "Confirm change" name = "B1" style = "border:1px solid #7D85A2; font-size: 9pt; background-color:rgb(210,232,255)" <%=canPay%> ID = "Submit1">&nbsp;&nbsp;
				<input type = "button" value = "Continue shopping" name = "B2" style = "border:1px solid #7D85A2; font-size: 9pt; background-color:rgb(210,232,255)" onclick = "window.location = '<%=Session("oldUrl")%>';" style = "font-size: 9pt" ID = "Button1">&nbsp;&nbsp;
				<input type = "button" value = "Cancel orders" name = "B3" style = "border:1px solid #7D85A2; font-size: 9pt; background-color:rgb(210,232,255)" OnClick = "clean()" style = "font-size: 9pt" <%=canPay%> ID = "Button2">&nbsp;&nbsp;
				<input type = "button" value = "To Cash desk " name = "B4" style = "border:1px solid #7D85A2; font-size: 9pt; background-color:rgb(210,232,255)" onclick = "window.location.href = 'payStep1.asp';" style = "font-size: 9pt" <%=canPay%> ID = "Button3">
			</blockquote><br>
			<div align = "center"><font color = "#FF0000"> Attention:</font><span class="style1">please</span>  confirm before 


 changeing books quantity and reduceing books type!<br>
		</form>
    </td>
  </tr>
</table>
<%  	
end sub


function ShowCartTable()
	dim Sum, canPay
	dim quantityArray, productArray, quantity, i
	dim strSQL, rsObj
%><br>
<table border = "1" cellpadding = "0" cellspacing = "0" width = "95%" bgcolor = "#FFFFFF" bordercolor = "#808080" style = "border-collapse: collapse">
	<tr > 
		<td align = "center" width = "108"  height = "22" > Purchase </td>
		<td align = "center" width = "103"  height = "22" >BookID</td>
		<td align = "center" width = "124"  height = "22" >Book name</td>
		<td align = "center" width = "136" height = "22" >Book price</td>
		<td align = "center" width = "133"  height = "22" >Books quantity </td>
		<td align = "center" width = "108"  height = "22" > Total price </td>
	</tr>
<%
Sum  =  0
If Len(Session("productList")) <>0 Then
	quantityArray  =  Split(Session("quantityList"), ", ")
	productArray  =  Split(Session("productList"), ", ")
	
	for i = 0 to UBound(productArray)
		strSQL  =  "SELECT * FROM product WHERE id = "&productArray(i)
		set rsObj = conn.execute (strSQL)
		
 		if Not rsObj.EOF or err then
			quantity  =  quantityArray(i)
			If quantity <=  0 Then quantity  =  1
			Sum  =  Sum + rsObj("memberPrice") * quantity
%>
	<tr> 
		<td Align = "center" width = "108">
			<input Type = "CheckBox" Name = "productID" Value = "<%=rsObj("id")%>" Checked ID = "Checkbox1">
		</td>
		<td align = "center" width = "103"><%=rsObj("id")%>  </td>
		<td align = "center" width = "124"><%=rsObj("name")%>  </td>
		<td align = "center" width = "136"><%=rsObj("memberPrice")%> </td>
		<td align = "center" width = "133"> 
          <input name = "quantity<%=rsObj("id")%>" value = "<%=quantity%>" size = "4" onKeyUp = "checknum(quantity<%=rsObj("id")%>)" id = "Text1">
</td>
			<td Align = "center" width = "108"><%=rsObj("memberPrice")*quantity%>yuan</td>
   </tr>
<%	
		end if
		set rsObj  =  nothing
	next
	canPay = ""
else
	canPay = "disabled"
end if
%>
	<tr> 
		<td Align = "Right" ColSpan = "6" height = "24"><font Color = "Red">Total price </font><font Color = "Red">:&nbsp;<%=Sum%>&nbsp;yuan<font color = "#ABABAB">(chinese)</font> 
	  &nbsp;&nbsp;</font></td>
    </tr>
</table>
<br><br>
<%
	'返回价格总数,以标识购物车内是否有图书
	ShowCartTable  =  canPay
end function
%>
<Script language=javascript>
	function clean(){ 
		if (confirm("确定要清空购物车?") == 1){
		window.location.href = "shopCart.asp?clear=yes"}
	}

	function checkNumNull(theform) {
		if (theform.value == "") {	
		alert("请填写购买图书的数量");
			//theform.newprice.focus();
			theform.focus();
			return false;
		}
	}
</Script>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -