标题:发一个购物车的类
只看楼主
belin2000
Rank: 3Rank: 3
等 级:论坛游侠
威 望:5
帖 子:975
专家分:194
注 册:2004-6-2
结帖率:0
 问题点数:0 回复次数:1 
发一个购物车的类

<% '简单购物车类 '朱永创 ' 2005-9-24 '如出现问题,请联系我(belin2000@163.com QQ:63905649) class shopping private bb(10) private aa(10) private cc(10) '对session赋值 function pushsession() session("car")=aa session("one")=bb session("num")=cc end function '初始化session数组的值 function checksession() if not isarray(session("car")) then pushsession() end if end function '取得session的数据 function getsession() for i=0 to 9 aa(i)=session("car")(i) bb(i)=session("one")(i) cc(i)=session("num")(i) next end function

'购买产品 function buy(goods,one,num) dim isok,i isok=false getsession() for i=0 to 9 if aa(i)="" then aa(i)=goods bb(i)=one cc(i)=num isok=true exit for end if next pushsession() if not isok then response.Write("<script language='javascript'>alert('你的购物车已满');history.back();</script>") end function '修改产品的数量 'num 数量值 'i,sessin的代号 ,num数量 function upnum(i,num) getsession() cc(i)=num pushsession() end function '删除1个产品 'num session("car")的代号 function delgoods(num) getsession() aa(num)="" bb(num)="" cc(num)="" pushsession() end function

'删除多个产品 function delall() dim i getsession() for i=0 to 9 aa(i)="" bb(i)="" cc(i)="" next pushsession() end function '购物车的产品数量 function carcount() dim j,i getsession() j=0 for i=0 to 9 if aa(i)<>"" then j=j+1 next response.Write(j) end function '购物车的总价钱 function money() dim i dim carmoney getsession() carmoney=0 for i=0 to 9 if bb(i)<>"" then carmoney=carmoney+bb(i)*cc(i) end if next response.Write(carmoney) end function '显示单物品信息 function onegood(one) response.Write("<table width=100% border=0 cellpadding=0 cellspacing=0>"&vbcrlf) response.Write("<tr>"&vbcrlf) response.Write("<td width=30% >"&session("car")(one)&"</td>") response.Write("<td width=25% >"&session("one")(one)&"</td>") response.Write("<td width=30% >"&session("num")(one)&"</td>") response.Write("<td width=15% ><a href=?action=del&num="&one&">删除</a></td>") response.Write("</tr>"&vbcrlf) response.Write("</table>"&vbcrlf) response.Write("<table width=100% border=0 cellpadding=0 cellspacing=0>"&vbcrlf) response.Write("<tr>"&vbcrlf) response.Write("<td width=100% height=1 bgcolor=#001122 ></td>") response.Write("<tr>") response.Write("</table>") end function '显示购物车的信息 function show() dim i response.Write("<table width=100% border=0 cellpadding=0 cellspacing=0>"&vbcrlf) for i=0 to 9 if session("car")(i)<>"" then response.Write("<tr><td colspan=3>"&vbcrlf) response.Write(""&onegood(i)&"</td>") response.Write("</tr>"&vbcrlf) end if next response.Write("<tr><td width=60% >共") carcount() response.Write("个产品</td><td width=40% >应付金额:") money() response.Write("</td><tr>") response.Write("</table>"&vbcrlf) response.Write("<table width=100% border=0 cellpadding=0 cellspacing=0>"&vbcrlf) response.Write("<tr>"&vbcrlf) response.Write("<td width=100% height=4 style=filter:progid:DXImageTransform.Microsoft.Gradient(startColorStr='#FFFFFF', endColorStr='#888888', gradientType='1') ></td>") response.Write("<tr>"&vbcrlf) response.Write("</table>"&vbcrlf) end function

end class %>

搜索更多相关主题的帖子: 购物车 session function private 
2005-09-26 12:16
fjfj1212
Rank: 1
等 级:新手上路
帖 子:113
专家分:0
注 册:2005-9-16
得分:0 
我头晕。。。。

我就是我!!! 永不退缩!!!
2005-09-26 20:35



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-28703-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.067503 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved