当前位置:首页 > 代码 > 正文

asp购物车经典代码(购物车代码js)

admin 发布:2023-04-10 01:00 126


今天给各位分享asp购物车经典代码的知识,其中也会对购物车代码js进行解释,如果能碰巧解决你现在面临的问题,别忘了关注本站,现在开始吧!

本文目录一览:

请问asp网页购物车代码中的如下代码如何解释啊,求帮助啊!

直接上代码注释:

%

'Session("ProductList") 是购物车

'ProductList 购物车临时变量 用于处理购物车里的商品

public ProductList '定义商品列表

if request("order")="产品更新" then '判断传过来的order参数 如果是产品更新

Session("ProductList")="" ' 清空购物车商品列表

end if

'以下是非产品更新情况下 取决于页面参数 order

ProductList = Session("ProductList") '把购物车里的产品列表给Productlist变量

'一个过程 作用想购物车里添加产品

Sub PutToShopBag(Prodid, ProductList) '参数:产品ID,购物车产品列表

If Len(ProductList) = 0 Then '如果购物车为空

ProductList = "'" Trim(Prodid) "'" '直接把要添加的商品给购物车 这是第一件商品

ElseIf InStr( ProductList, Prodid ) = 0 Then ' 如果购物车里有商品

ProductList = ProductList", '"Trim(Prodid)"'" '则把要添加的商品ID追加到最后 并用逗号隔开

End If

End Sub '过程结束

Product_Id = Trim(Request("Product_Id")) '接受传过来的商品ID参数 即要添加进购物车的商品ID

if instr(Product_Id,",")0 then '如果这不是一件商品而是用逗号分隔开的几件商品

idArr=Split(Product_Id, ",") '则把参数 Product_Id 以逗号为分隔符分割成熟组

for i = 0 to ubound(idArr) '遍历数组把这几件商品追加进购物车

PutToShopBag idArr(I), ProductList

next '追加完毕

else

PutToShopBag Product_Id, ProductList '如果是一件商品 则直接调用上面的那个过程追加商品至购物车

end if

Session("ProductList") = ProductList '把操作完的临时购物车变量ProductList 给购物车

if Productlist"''" then '如果购物车不为空 则计算购物车里的商品总价 通过sql语句调用数据库里的价格字段计算

sql="select * from Product where Product_Id in ("ProductList") order by Product_Id"

Set rs_price = conn.Execute(sql)

else '如果购物车为空

response.redirect "error.asp?error=007" '则跳转到错误页面

response.end '停止执行下面的代码

end if '结束

%

帮忙翻译asp购物车相关代码!

Sub PutToShopBag( hw_ID,basket_count, productList ,quantityList) '定义函数PutToShopBag()并传入接受4个参数值分别安顺序赋值给4个变量hw_ID,basket_count, productList ,quantityList

If Len(productList) = 0 Then ’如果productList变量的长度为0 条件成立则执行如下语句

productList = "" hw_ID "" ‘productList的值就等于hw_ID变量的值

quantityList="" basket_count "" ’quantityList变量的值就为basket_count变量的值

ElseIf InStr( productList",", hw_ID"," ) = 0 Then '否则 判断productList的值连接上字符","后是否包含hw_ID变量连接上字符","的值 =0表示不包含 条件成立则执行如下语句

productList = hw_ID "" ", " productList '为hw_ID变量连接上字符", "在连接上productList变量的值后赋值给productList变量

quantityList = basket_count ", " quantityList '同上

End If '结束条件选择语句if

session("productList")=productList '定义名为productList的session变量 值为productList变量的值

session("quantityList")=quantityList '同上

End Sub

Sub PutToShopBagsecond( hw_ID,basket_count, productList ,quantityList)

If Len(productList) = 0 Then

productList = "" hw_ID ""

quantityList="" basket_count ""

ElseIf InStr( productList",", hw_ID"," ) = 0 Then

productList = hw_ID "" ", " productList

quantityList = basket_count ", " quantityList

End If

session("productList")=productList

session("quantityList")=quantityList

End Sub

productList = session("productList")

quantityList = session("quantityList")

if Request("hw_ID")"" then

PutToShopBag Request("hw_ID"), "1",productList,quantityList

end if

session("productList")=productList

session("quantityList")=quantityList

Head="以下是您所选购的物品清单" '为Head变量赋值

If Request("clear") = "yes" Then '如果上一页传递过来的参数clear的值yes

productList = "" 'productList 变量的值为空

quantityList = "" '同上

session("productList") = productList'同上

session("quantityList") = quantityList '同上

End If

If Request("MySelf") = "Yes" Then

productList = ""

quantityList = ""

products = Split(Request("hwID"), ", ") '把 上一页传递过来的参数hwID的值以", "为分隔符 用split函数遍历为数组赋值给products

For I=0 To UBound(products) ' for 循环 Ubound(products)获取products数组的最大下标

j=UBound(products)-i 'products的最大下表减去i的值赋值给j变量 (下面应该是按照倒叙取值)

tempQuantity=Request("basket_count"products(j)) '获取同名的basket_count参数的第j+1个的值并复制给tempQuantity

if tempQuantity="" then tempQuantity=1 '如果tempQuantity的值为空则重新为tempQuantity变量赋值为1

' j=i

PutToShopBagsecond products(j), tempQuantity,productList,quantityList '函数中调用函数puToShopBagsecond 并传递4个参数products(j), tempQuantity,productList,quantityList(这句我也不太清楚调用函数应该是call 函数名(参数))

Next

session("productList") = productList ‘赋值语句

session("quantityList") = quantityList ‘赋值语句

End If

求解一段ASP代码(是购物车的)

'rs.Open sql,conn,1,1无法看到其他用户添加的新数据,但被其他用户删除的数据将变为不可访问,同时可以看到其他用户所作的修改。

'rs.Open sql,conn,1,3静态打开方式。在你使用数据是其他用户无法访问该数据

'rs.Open sql,conn,1,2动态的数据库打开方式,其他用户所进行的修改、删除和新建等工作都会立即在数据对象中体现出来,并且支持全部类型的数据移动方式,除非提供者不支持,否则也可以进行书签操作

'rs.Open sql,conn,-1不指定打开方式

%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%

!--#incl

ude file="manage/inc/config.asp"--

!--#include file="inc/conn.asp"--

!--#include file="inc/chk.asp"--

%

dim id,username,action

action=request.QueryString("action") '取得前页面传来的参数action和id以及从cookies中去的用户名分别存入变量aciton,id,name中

username=trim(request.cookies(cookieName)("username"))

id=request.QueryString("id")

set rs=server.CreateObject("adodb.recordset") '建立数据库连接,创建一个recordset对象rs

select case action '以下分情况对action进行判断

case "del" '当为del时候,表示删除执行语句delete from orders where actionid=前页面的参数actionid

conn.execute "delete from orders where actionid="request.QueryString("actionid")

response.redirect "car.asp" '然后页面跳转到car.asp这一页面

case "add" '当为add时候,表示增加。执行语句 select id,username from orders where username='"username"' and id="id" and state=6

rs.open "select id,username from orders where username='"username"' and id="id" and state=6",conn,1,1 '先检查购物车中是否已经存在这件货物,如果否,就添加到数据库

if not rs.eof and not rs.bof then '如果已经添加过了就弹出提示框 提示对不起,此商品已存在于您的购物车中,不可以重复添加

call MsgBox("对不起,此商品已存在于您的购物车中,不可以重复添加!","Close","None")

response.end

rs.close '关闭连接

else '当购物车中没有刚才要添加的记录的时候,进行添加

rs.close

rs.open "select id,username,state,paid from orders",conn,1,3

rs.addnew '添加一个新行,在recordset中

rs("id")=id '设置这一行各对应列的值

rs("username")=username

rs("state")=6

rs("paid")=0

rs.update '然后执行update操作将这一行插入到数据库中去

rs.close '关闭连接

set rs=nothing '清空对象,注意随时关闭连接和清空对象,否则很容易出错

call MsgBox("商品成功添加到你的购物篮!","Close","None") '弹出添加成功提示

response.end '返回

end if

end select

'选择此用户购物车里所有物品 ,可能要显示

rs.open "select orders.actionid,orders.id,product.name,product.price1,product.price2,product.discount from product inner join orders on product.id=orders.id where orders.username='"request.cookies(cookieName)("username")"' and orders.state=6",conn,1,1

%

html

head

meta http-equiv="Content-Type" content="text/html; charset=gb2312"

title网上书店/title

link href="style.css" rel="stylesheet" type="text/css"

asp购物车经典代码的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于购物车代码js、asp购物车经典代码的信息别忘了在本站进行查找喔。

版权说明:如非注明,本站文章均为 AH站长 原创,转载请注明出处和附带本文链接;

本文地址:http://ahzz.com.cn/post/42084.html


取消回复欢迎 发表评论:

分享到

温馨提示

下载成功了么?或者链接失效了?

联系我们反馈

立即下载