下面是购物车的代码,其中plist.asp是将用户选购商品的ID添加进商品列表中. <%@ LANGUAGE="VBSCRIPT" %> <!--#include file="plist.asp" --> <!--#include file="connections/xue.asp" --> <% strspbh = Request("spbh") if ((len(trim(strspbh)) = 0) or (strspbh = "undefined")) then strCheck = "no" end if
ProductList = Session("ProductList") Products = Split(Request("spbh"), ", ") For I=0 To UBound(Products) shangpin Products(I), ProductList Next Session("ProductList") = ProductList
Head="您所选购的商品如下" ProductList = Session("ProductList") If Len(ProductList) =0 Then Response.Redirect "nothing.asp" response.end end if
If Request("MySelf") = "Yes" Then ProductList = "" Products = Split(Request("spbh"), ", ") For I=0 To UBound(Products) shangpin Products(I), ProductList Next Session("ProductList") = ProductList End If If Len(ProductList) = 0 Then Response.Redirect "nothing.asp" response.end end if set rs=server.createobject("adodb.recordset") sql = "Select * From Product" sql = sql & " Where Product_Id In (" & ProductList & ")" rs.open sql,conn,3,3 %> <html>
<head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <title>购物车</title> <link href="ct.css" rel="stylesheet" type="text/css"> <style type="text/css"> <!-- .ct1 { font-family: "宋体", Verdana; font-size: 14px; font-style: normal; font-weight: normal; color: #333333; } .aa { font-family: "宋体", Verdana; font-size: 16px; color: #ef2e75; } .ss { font-family: "宋体", Verdana; font-size: 12px; color: #ef2e75; } .ll { border: 1pt dashed #CCCCCC; } .zz { font-family: "宋体", Verdana; font-size: 16px; color: #ff6600; font-weight: bold; } .ll2 { border: 1pt solid #CCCCCC; }
.sp { FONT-SIZE: 9pt; FILTER: DropShadow(color=#000000, OffX=1, OffY=1, Positive=1); COLOR: #000000; LINE-HEIGHT: 17px } .ct2 { font-family: "宋体", Verdana; font-size: 16px; color: #FF99FF; } .td2 { FONT-SIZE: 9pt; COLOR: #666666; LINE-HEIGHT: 20px } .style10 {color: #333333} .style12 {font-size: 10pt; color: #ef2e75; } --> </style> <link rel="stylesheet" type="text/css" href="style.css"> </head> <script language="Javascript"> //函数名:fucCheckNUM //功能介绍:检查是否为数字 //参数说明:要检查的数字 //返回值:1为是数字,0为不是数字 function fucCheckNUM(NUM) { var i,j,strTemp; strTemp="0123456789"; if ( NUM.length== 0) return 0 for (i=0;i<NUM.length;i++) { j=strTemp.indexOf(NUM.charAt(i)); if (j==-1) { //说明有字符不是数字 return 0; } } //说明是数字 return 1; }
function clean() { window.location.href="clear.asp" } </script> <SCRIPT language=javascript id=clientEventHandlersJS> <!-- function form1_onsubmit() { newprice="sl" & rs("Product_Id") if ((fucCheckNUM(document.FORM1.newprice.value)==0) ) { alert ("会员价有非法字符,请填写正确会员价。"); document.FORM1.newprice.focus(); return false; } //--> } </SCRIPT> <body topmargin="5">
<table width="80%" border="0" cellspacing="0"> <tr> <td width="80%" valign="top"><p align="center"> </p> <p align="center"> <font class="style12"><%=Head%></font></p> <!--webbot BOT="GeneratedScript" PREVIEW=" " startspan --><script Language="JavaScript"><!-- function GW_Form1(theForm) { var checkOK = "0123456789-"; var checkStr = theForm.<%="sl" & rs("Product_Id")%>.value; var allValid = true; var decPoints = 0; var allNum = ""; for (i = 0; i < checkStr.length; i++) { ch = checkStr.charAt(i); for (j = 0; j < checkOK.length; j++) if (ch == checkOK.charAt(j)) break; if (j == checkOK.length) { allValid = false; break; } allNum += ch; } if (!allValid) { alert(在"请输入正确的商品数量!" 域中,只能输入4个字符。); theForm.<%="sl" & rs("Product_Id")%>.focus(); return (false); } return (true); } //--></script><!--webbot BOT="GeneratedScript" endspan --><form Action="gouwuche.asp" Method="POST" name="GW_Form1" id="GW_Form1" onsubmit="return GW_Form1(this)"> <input type="hidden" name="MySelf" value="Yes"> <div align="center"><center> <table border="0" cellspacing="1" width="550" class=main bgcolor="#666666"> <tr bgcolor="#006699"> <td align="center" width="77" height="22" bgcolor="#ffffff"><font color="#333333" class="style10" style="font-size:14px ">商品编号</font></td> <td align="center" width="170" height="22" bgcolor="#ffffff"><font color="#333333" class="style10" style="font-size:14px ">商品名称</font></td> <td width="67" height="22" align="center" bgcolor="#ffffff" class="style10">单价</td> <td align="center" width="75" height="22" bgcolor="#ffffff"><font color="#333333" class="style10" style="font-size:14px ">数量</font></td> <td align="center" width="70" height="22" bgcolor="#ffffff"><font color="#333333" class="style10" style="font-size:14px ">购买</font></td> <td align="center" width="72" height="22" bgcolor="#ffffff"><font color="#333333" class="style10" style="font-size:14px ">总计</font></td> </tr> <% Sum = 0 While Not rs.EOF Quatity = CInt( Request( "sl" & rs("Product_Id")) ) If Quatity <= 0 Then Quatity = CInt( Session(rs("Product_Id")) ) If Quatity <= 0 Then Quatity = 1 End If Session(rs("Product_Id")) = Quatity Sum = Sum + ccur(rs("Product_NPrice")) * Quatity %> <tr> <td class="td2" align="center" width="77" bgcolor="#ffffff"><%=rs("Product_ID")%> </td> <td class="td2" align="center" width="170" bgcolor="#ffffff"><%=rs("Product_Name")%> </td> <td class="ss" align="center" width="67" bgcolor="#ffffff"><%=rs("Product_NPrice")%> </td> <td class="ss" align="center" width="75" bgcolor="#ffffff"><input Name="<%="sl" & rs("Product_Id")%>" id="<%="sl" & rs("Product_Id")%>" Value="<%=Quatity%>" Size="3"> <input name="B1" type="submit" id="B1" value="修改"></td> <td class="ss" Align="center" width="70" bgcolor="#ffffff"><input name="spbh" type="CheckBox" id="spbh" value="<%=rs("Product_Id")%>" checked> </td> <td class="ss" Align="center" width="72" bgcolor="#ffffff"><%=ccur(rs("Product_NPrice"))*Quatity%>.00元 </td> </tr> <% rs.MoveNext Wend %> <tr> <td Align="center" ColSpan="6" bgcolor="#ffffff"><font Color="Red" class="ss">费用总计: <%=Sum%>.00元</font></td> </tr> </table> </center></div><blockquote> <p align="center"> <input type="button" value="继续购物" name="B2" onclick="window.close();" style="font-size: 9pt"> <input type="button" value="订单取消" name="B3" OnClick="clean()" style="font-size: 9pt"> <input type="button" value="去收银台" onClick="window.open('ment.asp',window.close(), 'Sample', 'toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,copyhistory=yes,width=610,height=600,left=100,top=100')" name="b4"> </blockquote> </form> </td></tr></table> </div> <% rs.close conn.close %> </body> </html> 这个问题,到底哪里该改下???