读书人

购物车有关问题来者得分

发布时间: 2012-03-20 14:01:11 作者: rapoo

购物车问题,来者得分!
我做了一个购物系统,就在购物车那里出了点问题:我现在做的是没有购物都可以进入结帐中心,我是想改为,购物车空的时候就不能进入结帐中心.我现在给出结帐中心的一些主要的代码,大家看看怎么去判断?

<%
openconn1()
dim idArray(100),numArray(100)
if request.ServerVariables( "REQUEST_METHOD ")= "POST " then
'request.form( "submit ")= "确定购物 " then
for i=1 to ubound(split(session( "ProductList "), ", ",-1,1))
idArray(i)=trim(request.form( "id "&i))
numArray(i)=trim(request.form( "num "&i))
'response.write "产品名: "&getpartname(idArray(i))& "产品数量: "&numArray(i)& " <br> "
next
elseif request.form( "submit ")= "提交订单 " then
orderno=year(now)&month(now)&day(now)&hour(now)&minute(now)&second(now)
C_name=Trim(Request.Form( "C_name "))
type1=Trim(Request.Form( "type "))
postno=Trim(Request.Form( "postno "))
address=Trim(Request.Form( "add "))
tel=Trim(Request.Form( "tel "))
mobile=Trim(Request.Form( "mobile "))
email=Trim(Request.Form( "email "))
sn=Trim(Request.Form( "sn "))
remark=Trim(Request.Form( "remark "))

if c_name= " " or postno= " " or address= " " or mobile= " " then response.end
for i=1 to ubound(split(session( "ProductList "), ", ",-1,1))
idArray(i)=trim(request.form( "id "&i))
numArray(i)=trim(request.form( "num "&i))
sum=trim(request.Form( "sum "))
'response.write "产品名: "&getpartname(idArray(i))& "产品数量: "&numArray(i)& " <br> "
sql= "insert into [order](orderno,proname,retailprice,num,allprice) values( ' "&orderno& " ', ' "&getpartname(idArray(i))& " ', ' "&getprize(idArray(i))& " ', ' "&numArray(i)& " ', ' "&sum& " ') "
'response.Write sql
conn1.execute sql
next
sql= "insert into orderdetail(orderno,c_name,type,postno,address,tel,mobile,email,remark ) values( ' "&orderno& " ', ' "&c_name& " ', ' "&type1& " ', ' "&postno& " ', ' "&address& " ', ' "&tel& " ', ' "&mobile& " ', ' "&email& " ', ' "&sn& " ', ' "&remark& " ') "

conn1.execute sql
response.write " <script lanuage=javascript> alert( '提交订单成功,你的订单号为: "&orderno& " ') </script> "
end if


function getpartname(id)
sql= "select id,proname from products where id= ' "&id& " ' "
call getrsbysql(conn1,rs1,sql,1,1,0)
if rs1.bof and rs1.eof then
getpartname= "暂无 "
else
getpartname=rs1(1)
end if
end function
function getprize(id)
sql= "select id,RetailPrice from products where id= ' "&id& " ' "

call getrsbysql(conn1,rs2,sql,1,1,0)
if rs2.bof and rs2.eof then


getprize=0
else
if not isnumeric(rs2(1)) then
getprize=0
else
getprize=rs2(1)
end if
end if

end function
>

[解决办法]
for i=1 to ubound(split(session( "ProductList "), ", ",-1,1))前加上判断:
if session( "ProductList ")= " " or isnull(session( "ProductList ")) then
for ...

else
response.write "购物车为空 "
end if

读书人网 >ASP

热点推荐