shopcartformat.asp
来自「ASP+SQL Server动态网站开发从基础到实践教程」· ASP 代码 · 共 127 行
ASP
127 行
<%
'***********************************************************************
'格式化显示购物栏的商品信息
'*********************************************************************
Sub CartFormat (AllowDelete)
Dim Remove
Dim total
Dim bgclor
Dim isubtotal, i, scartItem, arrCart
scartItem = Session("cartItem")
arrCart = Session("MyCart")
Remove=""
If allowdelete="TRUE" then
Remove="Remove"
end if
bgcolor="#CCCCCC"
%>
<div align="center">
<center>
<table border="2" cellpadding="0" cellspacing="1" width="90%">
<tr>
<%
If remove<> "" then
%>
<td width="10%" bgcolor="<%=bgcolor%>">
<p align="center"><b><font color="#993333" face="Verdana" size="2">是否定购</font></b></td>
<%end if
%>
<td width="60%" bgcolor="<%=bgcolor%>">
<p align="center"><b><font color="#993333" face="Verdana" size="2">商品描述</font></b></p>
</td>
<td width="10%" bgcolor="<%=bgcolor%>"><p align="center"><b><font color="#993333" face="Verdana" size="2">定购数量</font></b></td></p>
<td width="10%" bgcolor="<%=bgcolor%>"><p align="center"><b><font color="#993333" face="Verdana" size="2">商品单价</font></b></td></p>
<td width="10%" bgcolor="<%=bgcolor%>">
<p align="center"><b><font color="#993333" face="Verdana" size="2">每种商品总价</font></b></td>
</tr>
<%
isubtotal = 0
For i = 1 to scartItem
%>
<TR bgColor=#99cccc>
<%
If remove<> "" then
%>
<TD width="10%"><INPUT name=selected<%= Cstr(i)%> type=checkbox value="yes" checked></TD>
<%
end if
%>
<TD width="60%"><%= arrCart(cProductname,i) %></TD>
<TD width="10%"><INPUT type="text" size=5 name=quantity<%= CStr(i) %> value="<%= arrCart(cQuantity,i) %>"></TD>
<TD align="right" width="10%"><%= FormatCurrency(arrCart(cUnitPrice,i),2) %></TD>
<TD align="right" width="10%"><%= FormatCurrency(arrCart(cUnitPrice,i) * arrCart(cQuantity,i),2) %></TD></TR>
<%
isubtotal = isubtotal + (arrCart(cUnitPrice,i) * arrCart(cQuantity,i))
Next
if remove="" then ' add other stuff during final checkout
AddOthers isubtotal, total, Session("smprice"), Session("Taxes") ,"Calculate"
Session("ordertotal")=total
else
response.write "<TR><TD></TD>"
If Remove<>"" then
response.write "<TD></TD>"
end if
%>
<TD colspan=2 bgColor=#339999><font color="#FFFFFF">总价</font></TD>
<TD align="right" bgColor=lightgoldenrodyellow><%= FormatCurrency(isubtotal,2) %></TD></TR>
</table>
</center>
</div>
<%
end if
end sub
Sub AddOthers (isubtotal, total, shipcost, itaxe, formatoption)
' if option="format" then don't recalculate tax
' Add fright, taxes to get total
Dim taxes
taxes=itaxe
Total=isubtotal
%>
<TR><TD></TD>
<TD colspan="2" bgColor=#339999><font color="#FFFFFF">商品总价</font></TD>
<TD align="right" bgColor=lightgoldenrodyellow><%= FormatCurrency(isubtotal,2) %></TD></TR>
<%
'response.write "shipping " & shipcost
if shipcost<>"" then
%>
<TR><TD></TD>
<TD colspan="2" bgColor=#339999><font color="#FFFFFF">送货总价</font></TD>
<TD align="right" bgColor=lightgoldenrodyellow><%= FormatCurrency(shipcost,2)%></TD></TR>
</TD></TR>
<%
Total=Total+shipcost
end if
' set values taxes in calulate Taxes in routine shoptax.asp
if ucase(formatoption)<>"FORMAT" then
CalculateTax isubtotal, total, shipcost, Taxes
Session("taxes")=taxes
end if
if Taxes<>"" then
If Taxes<>0 then
%>
<TR><TD></TD>
<TD colspan="2" bgColor=#339999><font color="#FFFFFF">缴税</font></TD>
<TD align="right" bgColor=lightgoldenrodyellow><%= FormatCurrency(taxes,2) %></TD></TR>
</TD></TR>
<%
Total=Total+taxes
end if
end if
%>
<TR><TD></TD></font>
<TD colspan="2" ><font size="4">总价</font></TD>
<font face="Arial, Arial, Helvetica">
<TD align="right" bgColor=lightgoldenrodyellow><b><%= FormatCurrency(total,2) %></b></TD></TR>
</TABLE></P>
<%
end sub
%>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?