当前位置:首页 » 网购平台 » asp购物车
扩展阅读
宁波奥德赛优惠价格 2021-03-15 14:26:02
丹尼斯购物卡能挂失么 2021-03-15 14:25:58
淘宝购物指纹验证失败 2021-03-15 14:24:44

asp购物车

发布时间: 2021-01-21 11:41:35

❶ asp实现购物车功能

这个怎么说呢。你首先要把购物车的流程写出来,无论什么程序都是需要业务流专程才能做出来的。你把流属程写出来了,代码就很简单了。既然你已经用cookie写出来了,那么你就不能做一个临时表来存储这些数据,用户登录就记录用户,用户没登录在他结帐的时候提醒登录。。(PS:这只是一个思路,授人以鱼,比如授人以渔。)代码给你了,你也只是交差,你可以自己先思考一下。确实写不了。。在Q我。

❷ asp的添加购物车代码。。执行不了。。高手指点下。。

按照你的说法,它应该没转跳到go_login.asp页面吧.
验证登陆那也没写上response.end()

'***************************
<%if session("MM_username")="" then
response.write "<script>alert('很抱歉,您还没有登录,您需要先登陆后才能进入您的购物车!');window.location.href='go_login.asp';</script>"
response.end()
end if%>
'就执行到这,我登录后进入该页就没有反应了,下面的代码始终没有执行
<%
if session("cart")="" or (not IsObject(session("cart"))) then
set Session("cart")=server.CreateObject("Scripting.Dictionary")
end if
Set cart=Session("cart")
proctID=Cstr(Request("Proct_ID"))
dim detail(1)
detail(0)=1
if Request("Proct_ID")<>"" then
if cart.Exists(proctID) then
Response.Write("<script>alert('对不起,您已经购买了该产品!');location='proct.asp';<script>")
Response.End
end if
cart.add proctID,detail

Response.Write("<script>alert('成功添加该产品!');location='proct.asp';<script>")
end if
%>

'*****************
如果还不行,就设置
on error resume next查错语句,再配和在某个点设置response.write(变量a)
response.end()
'这样可以在那个点可以追踪到那个变量a的值,一步步查,看那里有问题

❸ 想求一个完整的ASP购物车代码

示用户信息
首先登陆: 就是判断数据库里的记录 是否存在用户名字段=帐号 and 密码字段=密码 如果有这条记录 那么就是登陆成功 用session记住他的帐号 这就是登陆
购物车: 就是有个表 记录商品的唯一值的字段(一般是id字段)和用户的唯一字段(一般是帐号) 这样这个商就属于这个人购物车内的商品了 一般有个商品个数字段 记录这个人买了多少件这个商品
显示:(select * from [表] where 条件)这个是查询sql 你应该会用吧 如果是查询某人的购物车 就这样写(select * from [购物车表] where [用户名字段] = 用户)上面已经说了 购物车表里要有个用户名字段 来记录是哪个用户存放的物品
删除:(delete from [购物车表] where [id]=记录id and [用户名字段]=用户)上面显示里已经获取到记录的id和其他信息 在这里只需要id和用户名 其实只需要id就可以要用户名是为了更保险 有了用户名字段的限制 就只样自己删除自己的记录
显示用户信息:如果你不会显示用户信息的话 那你还是去看看sql吧 (select * from [会员表] where [用户名]=用户名)获取这个sql的记录集
response.write(rs.("用户名"))这样就能在屏幕上打印出用户名字段的内容 其他字段同上

❹ asp做的购物车,现在每点一款商品加到购物车后

同样原理,比如商品的ID是29,价格是88,那么把这个商品加到购物车,session("proctList")就记录了这个29,session("Price")就记录88;

❺ 购物车程序问题(asp+js+cookie)

以下是贴上来的,我以前也过的。我可以打包发给你。留言给我告诉我邮箱
cookie_buy.asp源代码
<%session("username")="Inghot"%>
<p>
<input type="image" src="image/buy.gif" name="Submit" value="购买" title="购买" onClick="writeCookie('<%=session("username")%>','111','苹果1','1',11)" />
<input type="image" src="image/buy.gif" name="Submit" value="购买" title="购买" onClick="writeCookie('<%=session("username")%>','222','苹果2','1',12)" />
<input type="image" src="image/buy.gif" name="Submit" value="购买" title="购买" onClick="writeCookie('<%=session("username")%>','333','苹果3','1',13)" />
<input type="image" src="image/buy.gif" name="Submit" value="购买" title="购买" onClick="writeCookie('<%=session("username")%>','444','苹果4','1',14)" />
<input type="image" src="image/buy.gif" name="Submit" value="购买" title="购买" onClick="writeCookie('<%=session("username")%>','555','苹果5','1',15)" />
<input type="image" src="image/buy.gif" name="Submit" value="购买" title="购买" onClick="writeCookie('<%=session("username")%>','666','苹果6','1',16)" />
<input type="image" src="image/buy.gif" name="Submit" value="购买" title="购买" onClick="writeCookie('<%=session("username")%>','777','苹果7','1',17)" />
<input type="image" src="image/buy.gif" name="Submit" value="购买" title="购买" onClick="writeCookie('<%=session("username")%>','888','苹果8','1',18)" />
</p>
<p><a href="cookie_show.asp">去埋单</a></p>
<p style="text-align:center;">Copyright <a href="http://inghot.cn" target="_blank">Inghot.cn</a></p>
<script language="javascript">
//document.cookie="<%'=session("username")%>"+"=";//清空cookie
//writeCookie("cookie名称","产品ID","产品名称","产品数量",价格)
function writeCookie(name, ID, pro, num, pri)
{
var test=false;
var values="," + escape(ID) + "#" + escape(pro) + "#" + escape(num) + "#" + escape(pri);
var cookieValue = readCookie(name);
sss=cookieValue.split(",")
for (i=0;i<sss.length;i++){
s=sss[i].split("#");
for(j=0;j<s.length;j++){
if(s[0]==ID)
{
cookieValue=cookieValue.replace(","+sss[i],"");
nums=s[2];
test=true;
alert('你已经购买过些物品,将只在数量上添加!');
break;
}
}
}
if (test)
{
document.cookie = name + "=" + cookieValue+ "," + escape(ID) + "#" + escape(pro) + "#" + escape(parseInt(num)+parseInt(nums)) + "#" + escape(pri);
test=false;
}
else
{
document.cookie = name + "=" + cookieValue+values;
alert ('购买成功');
}

}

function readCookie(name)
{
var cookieValue = "";
var search = name + "=";
if(document.cookie.length > 0)
{
offset = document.cookie.indexOf(search);
if (offset != -1)
{
offset += search.length;
end = document.cookie.indexOf(";", offset);
if (end == -1) end = document.cookie.length;
cookieValue = document.cookie.substring(offset, end)
}
}
return cookieValue;
}
</script>
cookie_shop.asp源代码
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>你的所购的物品</title>
<style type="text/css">
body {font-size:13px;}
.tb_b {border-bottom-width: 1px;border-bottom-style: dotted;border-bottom-color: #00A600;}
.tb_t {border-bottom-width: 1px;border-bottom-style: dotted;border-bottom-color: #00A600;}
.tb_tb {border-bottom-width: 1px;border-bottom-style: dotted;border-bottom-color: #00A600;border-top-width: 1px;border-top-style: dotted;border-top-color: #00A600;}
.tb_tbl {border-top-width: 1px;border-bottom-width: 1px;border-left-width: 1px;border-top-style: dotted;border-bottom-style: dotted;border-left-style: dotted;border-top-color: #00A600;border-bottom-color: #00A600;border-left-color: #00A600;}
.tb_bl {border-bottom-width: 1px;border-left-width: 1px;border-bottom-style: dotted;border-left-style: dotted;border-bottom-color: #00a600;border-left-color: #00a600;}
</style>
<script language="javascript">
<!--//
//name购物车名称
function readCookie(name)
{
var cookieValue = "";
var search = name + "=";
if(document.cookie.length > 0)
{
offset = document.cookie.indexOf(search);
if (offset != -1)
{
offset += search.length;
end = document.cookie.indexOf(";", offset);
if (end == -1) end = document.cookie.length;
cookieValue = document.cookie.substring(offset, end)
}
}
return cookieValue;
}//readCookie(name) 此函数为返回已购买的所有内容,包括 物品ID,物品单价,物品名称,物品数量

function stringToInteger (inputString)
{
return parseInt(inputString);
}//stringToInteger(inputString) 返回由字符串(inputString)转换所得到的整数

function isNotaNumber (inputString)
{
return isNaN(inputString);
}//isNotaNumber(inputString) 返回一个 Boolean 值,指明inputString是否是保留值NaN(不是数字)

function UpdateCookie(name,Ids)
{
var buy_num=document.getElementById(Ids);
value=buy_num.value;
s=value.split("#");
value=escape(s[0])+"#"+escape(s[1])+"#"+escape(s[2])+"#"+escape(s[3])
var vvv="";
vvv=readCookie(name);//返回所有购买的内容
vvv=vvv.replace(','+value,"");//把要删除的内容和其前面的","一起置空
document.cookie = name + "=" + vvv;//再把新的内容写入cookie里面
}//UpdateCookie(name, value) 删除value这个内容

function ModifyCookie(name, valuex, ID, pro, num, pri)
{
var vvv="";
vvv=readCookie(name);//返回购买的所有内容,包括 物品ID,物品名称,物品数量,物品单价
s=valuex.split("#");
valuex=escape(s[0])+"#"+escape(s[1])+"#"+escape(s[2])+"#"+escape(s[3])
vvv=vvv.replace(','+valuex,"");//把要修改的内容去掉
document.cookie = name + "=" + vvv + "," + escape(ID) + "#" + escape(pro) + "#" + escape(num) + "#" + escape(pri);//加上修改后得到的内容
//location.reload();
location.href='?';
}//ModifyCookie(name, valuex, ID, pro, num, pri) 修改内容,valuex为修改前的内容,value1-value4为修改后的内容

function clears()
{
document.cookie="<%=session("username")%>"+"=";
window.location.href='cookie_show.asp';
}//清除COOKIE

function AllPrice(num)
{
var All=document.getElementById("all");
All.innerHTML=num;
}//显示价格
//-->
</script>

</head>

<body>
<table width="800" border="1" align="center" cellpadding="0" cellspacing="0" bordercolorlight="#00A600" bordercolordark="#FFFFFF">
<form name="buyForm" action="result.asp" method="post" target="_self">
<tr>
<td align="center"><img src="image/title_ico_01.gif" alt="购物车" width="165" height="68" /></td>
</tr>
<tr>
<td height="25"><img src="image/Buy_ico.gif" width="26" height="17" /> 所有商品总价 <span id="all" style="color:#FF0000;"></span>元 <span style="cursor:hand;" onClick="clears();">清空购物车</span>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="4%" height="25" align="center" class="tb_tb">序号</td>
<td width="44%" align="center" class="tb_tbl">物品名称</td>
<td width="12%" align="center" class="tb_tbl">物品数量</td>
<td width="15%" align="center" class="tb_tbl">物品单价/元</td>
<td width="16%" align="center" class="tb_tbl">物品总价/元</td>
<td width="9%" align="center" class="tb_tbl">操作</td>
</tr>
<%
if session("username")<>"" then
buylist=request.Cookies(session("username"))'返回name为session("username")的cookie的内容
buylist_v=split(buylist,",")'用","把他们分开
for x=1 to ubound(buylist_v)'ubound 返回在buylist_v数组最大的维数,VBS数组下标为0(开始)
buylist_v_v=split(buylist_v(x),"#")'buylist_v_v为第一组数,即第x次购物的内容
buylist_v_x=buylist_v(x)'buylist_v_x为第x次购物的内容,与buylist_v(x)同
if buylist_v(x)<>"" then'判断第x购物内容是否为空
if(ubound(buylist_v_v))<3 then
response.write("<script>alert('出现错误');document.cookie="""&session("username")&"""+"""=""";location.href='?';</script>")
response.End()
end if
ProID=buylist_v_v(0)'有四个内容读四次,这个为 物品ID
ProName=buylist_v_v(1)'这个为 物品名称
ProNum=buylist_v_v(2)'这个为 物品数量
ProPrice=buylist_v_v(3)'这个为 物品单价
AllPrice=AllPrice + (ProNum*ProPrice)
%>
<tr onMouseOver="this.style.backgroundColor='#F0FFEC'" onMouseOut="this.style.backgroundColor=''">
<td height="25" align="center" class="tb_b"><%=x%>
<input type="hidden" name="ID_<%=x%>" id="ID_<%=x%>" value="<%=ProID%>" /></td>
<td align="center" class="tb_bl"> <%=ProName%>
<input type="hidden" name="buy_<%=x%>" id="buy_<%=x%>" value="<%=buylist_v(x)%>" /></td>
<td align="center" class="tb_bl"><input name="num_<%=x%>" type="text" onChange="if(isNotaNumber(this.value)==true){alert('请输入整数数字');this.value=1;}else{this.value=stringToInteger(this.value);};ModifyCookie('<%=session("username")%>','<%=buylist_v(x)%>','<%=ProID%>','<%=ProName%>',this.value,'<%=ProPrice%>');" value="<%=ProNum%>" size="10" maxlength="5" /></td>
<td align="center" class="tb_bl"> <%=ProPrice%>
<input type="hidden" name="pri_<%=x%>" id="pri_<%=x%>" value="<%=ProPrice%>" /></td>
<td align="center" class="tb_bl"> <%=ProPrice*ProNum%></td>
<td align="center" class="tb_bl"><img src="image/quit.gif" width="48" height="20" id="quit" name="quit" value="放弃" onClick="UpdateCookie('<%=session("username")%>','buy_<%=x%>');location.href='?';" /></td>
</tr>
<%
end if
next
response.write("<script>AllPrice('"&AllPrice&"');</script>")
end if
%>
</table>
</td>
</tr>

<tr>
<td height="25" align="center" style="display:block; vertical-align:middle;"><input type="image" value="提交" src="image/okay.gif" width="60" height="25" /> <img src="image/cancel.gif" width="60" height="25" border="0" title="取消" onClick="clears();" /></td>
</tr>
</form>
</table>

<p><a href="cookie_buy.asp">返回购物</a></p>
<p style="text-align:center;">Copyright <a href="http://inghot.cn" target="_blank">Inghot.cn</a></p>
</body>
</html>

result.asp源代码
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>结果</title>
</head>

<body>
<p>
<%
nums=request.Form.count
price=0
id=""
num=""
'循环读出提交过来的物品ID和数量,价格
'for i=1 to int(nums/3)
' id =id & request.Form("ID_"&i) & "|"
' num =num & request.Form("num_"&i) & "|"
' pri = pri & request.Form("pri_"&i) & "|"
'next
'response.write(id&"@"&num&"@"&pri&"<br />")

'当然一般价格是不会到这里得到的,所以取了个ID过来..这样再根据ID去库里取价格了
for i=1 to int(nums)
id = request.Form("ID_"&i)
num = request.Form("num_"&i)
pri = request.Form("pri_"&i)
price=price+(pri*num)
next
response.write("总共:"&price&"元")
%>
</p>
<p><a href="cookie_buy.asp">返回购物</a> <a href="cookie_show.asp">返回结算</a></p>
<p style="text-align:center;">Copyright <a href="http://inghot.cn" target="_blank">Inghot.cn</a></p>
</body>
</html>

❻ ASP怎么实现购物车商品按店铺分类

。。。商品表单、得有店铺分类的字段,按照字段id分开提取就好了

❼ ASP如何更改购物车中商品数量和计算总价

这是因为当购物车有两种或以上的商品时,你的actionid的值就会变成形如"12, 22, 25"的形式,成了字符串,而不是数值型,所以会出错,
我帮你修改了一下,就是把那个form表单位置改改就行了,改成每个商品都在自己的一个form表单里,这样就不会出错了!!
<%
Set conn = Server.CreateObject("ADODB.Connection")
conn.open mallDSN
set rs=server.createobject("ADODB.Recordset")
rs.open "select actionid,id,cpsl,yunfei,proctnum,goods,style,state,paid from orders1 where username='"&username&"' and yunfei=0 ",conn,1,3
do while not rs.eof%>
<form name="form" method="post" action="add.asp?action=cpsl&actionid=<%=rs("actionid")%>">
<tr bgcolor="#FFFFFF">
<td width="7%" height="89" align="center" style='PADDING-LEFT: 5px'><input name="id" type="checkbox" checked="checked" value="<% = rs("id") %>" />
</td>
<td align="left" style='PADDING-LEFT: 5px' width="16%"><div align="center"><img src="<% = rs("goods")%>" width="75" height="75" border="0" /></div></td>
<td align="center" width="13%"><a class="a5" href="proct.asp?id=<% = rs("id") %>" target="_blank">
<% = rs("proctnum") %>
</a></td>
<td align="center" width="13%"><font color="#FF0000"> <%=rs("paid")%></font> 元</td>
<td align="center" width="13%"><font color="#FF0000">
<input name="cpsl" type="text" id="cpsl" style="font-size:12px" value="<% = rs("cpsl")%>" size=3 maxlength=20>
</font></td>
<td align="center" width="13%">
<input type="submit" name="Submit4" value="修改"></td>
<td align="center">
<%
response.Write "<a href=add.asp?action=del&actionid="&rs("actionid")&">"
response.Write "<img src=images/trash.gif border=0></a></td></tr></form>"
rs.movenext
loop
rs.close
set rs=nothing
response.write "<tr><td height=36 colspan=6 bgcolor=#FFFFFF ><div align=center> "
if action<>"addtocart" then
%>
<input name="Submit22" type="button" onclick="MM_goToURL('parent','proct.asp');return document.MM_returnValue" value="继续购物" />
<input name="Submit23" type="button" value="去收银台" onclick="this.form.action='zxoderok.asp';this.form.submit()" />
<%
end if
%>
</td>
</tr>
</table>

试试看,还有问题就给我在网络里留言!

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

Sub PutToShopBag( hw_ID,basket_count, proctList ,quantityList) '定义函数PutToShopBag()并传入接受4个参数值分别安顺序赋值给4个变量hw_ID,basket_count, proctList ,quantityList
If Len(proctList) = 0 Then ’如果proctList变量的长度为0 条件成立则执行如下语句
proctList = "" & hw_ID & "" ‘proctList的值就等于hw_ID变量的值
quantityList="" & basket_count & "" ’quantityList变量的值就为basket_count变量的值
ElseIf InStr( proctList&",", hw_ID&"," ) <= 0 Then '否则 判断proctList的值连接上字符","后是否包含hw_ID变量连接上字符","的值 <=0表示不包含 条件成立则执行如下语句
proctList = hw_ID & ""& ", " &proctList '为hw_ID变量连接上字符", "在连接上proctList变量的值后赋值给proctList变量
quantityList = basket_count & ", " &quantityList '同上
End If '结束条件选择语句if
session("proctList")=proctList '定义名为proctList的session变量 值为proctList变量的值
session("quantityList")=quantityList '同上
End Sub
Sub PutToShopBagsecond( hw_ID,basket_count, proctList ,quantityList)
If Len(proctList) = 0 Then
proctList = "" & hw_ID & ""
quantityList="" & basket_count & ""
ElseIf InStr( proctList&",", hw_ID&"," ) <= 0 Then
proctList = hw_ID & ""& ", " &proctList
quantityList = basket_count & ", " &quantityList
End If
session("proctList")=proctList
session("quantityList")=quantityList
End Sub

proctList = session("proctList")
quantityList = session("quantityList")
if Request("hw_ID")<>"" then
PutToShopBag Request("hw_ID"), "1",proctList,quantityList
end if
session("proctList")=proctList
session("quantityList")=quantityList

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

If Request("clear") = "yes" Then '如果上一页传递过来的参数clear的值yes
proctList = "" 'proctList 变量的值为空
quantityList = "" '同上
session("proctList") = proctList'同上
session("quantityList") = quantityList '同上
End If
If Request("MySelf") = "Yes" Then
proctList = ""
quantityList = ""
procts = Split(Request("hwID"), ", ") '把 上一页传递过来的参数hwID的值以", "为分隔符 用split函数遍历为数组赋值给procts
For I=0 To UBound(procts) ' for 循环 Ubound(procts)获取procts数组的最大下标
j=UBound(procts)-i 'procts的最大下表减去i的值赋值给j变量 (下面应该是按照倒叙取值)
tempQuantity=Request("basket_count"&procts(j)) '获取同名的basket_count参数的第j+1个的值并复制给tempQuantity
if tempQuantity="" then tempQuantity=1 '如果tempQuantity的值为空则重新为tempQuantity变量赋值为1
' j=i
PutToShopBagsecond procts(j), tempQuantity,proctList,quantityList '函数中调用函数puToShopBagsecond 并传递4个参数procts(j), tempQuantity,proctList,quantityList(这句我也不太清楚调用函数应该是call 函数名(参数))
Next
session("proctList") = proctList ‘赋值语句
session("quantityList") = quantityList ‘赋值语句
End If

❾ ASP购物车的问题!求教!

看起来你要往数据库复里面插数据制哦?
那 rsCheck.open strsql,conn,1,1 该改成 3,2啊
这个函数干吗啊?看不懂哦…… 既然是SUB ,怎么没有 call puttoshopbag 啊?
<%
Sub PutToShopBag( Prodid, ProctList )
If Len(ProctList) = 0 Then
ProctList =Prodid
ElseIf InStr( ProctList, Prodid ) <= 0 Then
ProctList = ProctList&", "&Prodid &""
End If
End Sub
%>

你写了那么多request,总该把先前提交的那个表单贴贴啊……你好象连该页的地址都没有写啊!

“参数类型不正确,或不在可以接受的范围之内,或与其他参数冲突”……

我怀疑可能是="select ID,proct_name,Price,item_no from Proct where ID in ("&Session("ProctList")&")

这里的session错了

❿ asp 购物车代码问题

<td><input type="button" onclick="javascript:document.form1.action='update.asp?rowcount=<%=i%>&pid=<%=rs(1)%>&pcount=<%=rs(3)%>';document.form1.submit();"value="确认修改"></td>
改为
<td><input type="button" onclick="javascript:document.form1.action='update.asp?id=<%=rs("Id")%>&rowcount=<%=i%>';document.form1.submit();"value="确认修改"></td>

<%

'这里需要注意在上个页面,有个i值,在这里就用到了,你要指明修改的是哪一行记录

......

response.redirect("mycar.asp")'执行完之后重新跳转到mycar.asp

%>

改为

<%
'只需商品id和修改后的数量值

dim id

id=request.querystring("id")

pcount=request.querystring("pcount")

sql="update buy set pcount ='"&pcount&"' where Id="&id

conn.execute sql

conn.close

set conn=nothing

response.redirect("mycar.asp")'执行完之后重新跳转到mycar.asp

%>