Ghost全自动系统备份光盘正式版 V4.5 | 硬盘版 V2.0 | 排行榜 TOP50 | 图文推荐 | 玩小游戏
首页 >> Asp编程 >> Asp实例教程 >> asp网上购物车实例代码(3)

asp网上购物车实例代码(3)

时间:2007-10-3 网友评论条 【

六、 UpdateCart.asp

   接收AddtoCart.asp传递来的prodID、prodName、prodPrice和OrderQty,加上客户的Session编号,存入Cart表中。

  1、 添加记录集cartRec,设置数据源为Select * From Cart

  2、 添加更新数据的代码:

<Script Language=Javascript Runat=Server>
function cartRec_onbeforeopen(){
if(Request("InCart")==0) 
{
newSQL="Select * From Cart";
}//不在购物车中,取出所有数据
else 
{
newSQL="Select * From Cart Where SessionID="+Session.SessionID;
}//已经在购物车中,取出唯一的数据,准备修改数据
cartRec.setSQLText(newSQL);
}
function cartRec_ondatasetcomplete(){
if(Request("InCart")==0) //如果不在购物车中,添加新纪录
{
fields=new Array("ProductID","ProductName"Quantity","SessionID");
values=new Array(Request("prodID"),Request("prodName"),Request("OrderQty"),Session.SessionID);
cartRec.AddImmeidate(fields,values);
}
else//如果已经在购物车中,更新购买数量
{
cartRec.fields.setValue("Quantity",Request("OrderQty"));
}
Response.Redirect("ViewCart.asp");
</Script>

站长工具
英文域名注册及Whois查询:
相关文章
loading 请稍等,评论加载中...

Aspxhome.com. 中国Asp之家. 版权所有

闽ICP备06017341号