业余爱好求救·等到容颜老了(关于获取值问题)

dean8828 2009-12-04 09:59:59
一个页面b2b.asp那里有2个价格,分别是<%=price%>和<%=price2%>
只有2个按钮,一样的代码为:
<input name="click1" type="button" onClick="window.open('check.asp?ProdId=<%
if rs2("stock")>0 then
response.write rs2("id")&"','','scrollbars=yes,width=760,height=500')"
else response.write "alert('对不起,库存不足,请过段时间再来购买该商品!');window.close();"
end if %> " class="greenbuttoncss" value="放入购物车" />



现在,通过点击这2个按钮,都可以进入购物车页面check.asp

但我写的时候,我选择了if 语句作为判断

可是不知道为甚么就是获取不了价格的值
如果只有一个价格<%=price%>或<%=price2%>,不用IF语句,都能获取指和计算

现在我给出check.asp的代码,希望有人能帮我改下



<%
Sub PutToShopBag( Prodid, ProductList )
If Len(ProductList) = 0 Then
ProductList =Prodid
ElseIf InStr( ProductList, Prodid ) <= 0 Then
ProductList = ProductList&", "&Prodid &""
End If
End Sub
%>
<head>
<title><%=webname%>--您的购物车</title>
<link href="1.css" rel="stylesheet" type="text/css" />
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="Robots" content="index,follow">
</head>
<body text="#000000" leftmargin="0" topmargin="0">
<%
ProductList = Session("ProductList")
Products = Split(Request("Prodid"), ",")
For I=0 To UBound(Products)
PutToShopBag Products(I), ProductList
Next
Session("ProductList") = ProductList

if request("payment")="去收银台" then
response.redirect "b2b_ddlcsys.asp?action=1"
end if

If Request("cmdShow") = "Yes" Then
ProductList = ""
Products = Split(Request("ProdId"), ", ")
For I=0 To UBound(Products)
PutToShopBag Products(I), ProductList
Next
Session("ProductList") = ProductList
End If
If Len(Session("ProductList")) = 0 Then
Response.write "<table height=100% width=100% ><tr><td align=center>您的购物车为空,<a href=index.asp><b>继续购物</b></a> <a href=""JavaScript:onClick=window.close();""><B>关闭窗口</B></a></td></tr></table>"
Response.end
end if
%>


<form action="check.asp" method="POST" name="check">
<table width="700" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td align="center"><img src="imgs/sc.png" width="300" height="60" /></td>
</tr>
<tr>
<td><table cellspacing="0" cellpadding="0" align="center" width="100%" bgcolor="#CCCCCC">
<%
Set rsCheck=Server.CreateObject("ADODB.RecordSet")
strsql="select id,name,price,price2,amount,stock,pic from product where id in ("&Session("ProductList")&") order by id"
rsCheck.open strsql,conn,1,1
Sum = 0
sum2 =0
Quatity = 1
Do While Not rsCheck.EOF
Quatity = CInt( Request.Form( "Q_" & rsCheck("ID")) )
If Quatity <= 0 Then
Quatity = CInt( Session(rsCheck("ID")) )
If Quatity <= 0 Then Quatity = 1
End If
Session(rsCheck("ID")) = Quatity
IF rsCheck("Stock") < Quatity Then
Quatity = 1
Session(rsCheck("ID")) = 1
response.write "<script language=javascript>alert('对不起,"&rsCheck("Name")&"暂时库存不足,请过段时间再来购买该商品!');window.close();</script>"
Response.End()
Conn.Close
Set Conn = Nothing
End IF

'Dim Price
Price = Round(rsCheck("Price"),2)
price2 = round(rscheck("price2"),2)
Sum = Sum + Price * Quatity
sum2 = sum2 + price2 * Quatity
sum2 = round(sum2,2)
Sum=Round(Sum,2)
%> <tr bgcolor="#f7f7f7" height="25" align="center">
<td width="40" bgcolor="#f7f7f7"> <input type="CheckBox" name="ProdId" value="<%=rsCheck("ID")%>" Checked></td>
<td width="141" bgcolor="#FFFFFF"><a href="#### target="_blank"><img src="image\<%=rsCheck("Pic")%>" width="100" height="100" border="0"></a></td>
<td width="491" bgcolor="#FFFFFF"><table width="98%" border="0" cellpadding="7" cellspacing="1" bgcolor="#f2f2f2">
<tr>
<td width="17%" align="right" bgcolor="#f7f7f7" class="text">商品名称:</td>
<td colspan="5"><strong><%=rsCheck("Name")%></strong></td>
</tr>
<tr>
<td align="right" bgcolor="#f7f7f7" class="text">数量:</td>
<td width="20%" bgcolor="#FFFFFF"><input type="Text" name="<%="Q_" & rsCheck("ID")%>" value="<%=Quatity%>" size="1" class="input_sr">
<input name="imageField" type="image" src="imgs/gx.gif" align="middle"></td>
<td align="right" width="20%" bgcolor="#f7f7f7" class="text">成交价:</td>
<td width="15%" bgcolor="#FFFFFF" class="text"><%=Price %> 元</td>
<td align="right" width="15%" bgcolor="#f7f7f7" class="text">总计:</td>
<td bgcolor="#FFFFFF" class="text"><%=Round(Price * Quatity,2) %> 元</td>
</tr>
</table></td>
</tr>
<%
rsCheck.MoveNext
Loop
rsCheck.close
set rsCheck=nothing
%>
</table></td>
</tr>
<tr>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="75%" class="text">价格总计:<%=Round(Sum,2) %></td>
<td><input name="payment" type="submit" class="greenbuttoncss" value="去收银台">
<input name="button" type="button" class="greenbuttoncss" onClick="javascript:window.close()" value="继续购物" language=javascript></td>
</tr>
</table></td>
</tr>
</table>
</form>
</body>
</html>




...全文
99 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
dean8828 2009-12-04
  • 打赏
  • 举报
回复
<td width="15%" bgcolor="#FFFFFF" class="text"><%=Price %> 元</td>

我想把这个<%=price%>改成一段if语句,判断用户点击那个按钮,然后选择使用哪个价格

如 if ``` then 价格1 else 价格2 end if

但是我不知道是不是写错了,获取不了值

dean8828 2009-12-04
  • 打赏
  • 举报
回复
之前每样产品只有一个价格的时候,获取的到,是正常使用的。
dean8828 2009-12-04
  • 打赏
  • 举报
回复
b2b.asp 每样产品有个2个价格<%=price%>和 <%=price2%> ,分别赋予2个按钮可以点击购买,都可以进入check.asp,按钮代码如上
因为2个按钮代码都一样
现在问题出在check.asp的代码上,我之前写了一些判断语句,但是都无法获取价格。

lzp4881 2009-12-04
  • 打赏
  • 举报
回复
说什么呢?越看越糊涂,整理一下思路
dean8828 2009-12-04
  • 打赏
  • 举报
回复
%>_<%
dean8828 2009-12-04
  • 打赏
  • 举报
回复
<input name="click1" id="click1" type="button" onClick="window.open('check.asp?price=1&ProdId=<%
if rs2("stock")>0 then
response.write rs2("id")&"','','scrollbars=yes,width=760,height=500')"
else response.write "alert('对不起,库存不足,请过段时间再来购买该商品!');window.close();"
end if %> " class="greenbuttoncss" value="放入购物车" /><input name="click2" id="click2" type="button" onClick="window.open('check.asp?price=2&ProdId=<%
if rs2("stock")>0 then
response.write rs2("id")&"','','scrollbars=yes,width=760,height=500')"
else response.write "alert('对不起,库存不足,请过段时间再来购买该商品!');window.close();"
end if %> " class="greenbuttoncss" value="放入购物车" />

2个按钮的代码
dean8828 2009-12-04
  • 打赏
  • 举报
回复
<% if name=click1 then
response.Write(price)
elseif name=click2 then
response.write(price2)
end if
%> 元</td>

这是我判断价格的语句,可是不管按那个按钮输出之后还price的价格
dean8828 2009-12-04
  • 打赏
  • 举报
回复
可以详细一点吗。。。我比较钝
2009-12-04
  • 打赏
  • 举报
回复
在购买的按钮上加个参数
'check.asp?price=1&ProdId
'check.asp?price=2&ProdId

28,406

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧