标题:同时用url传值与表单提交,虽变量不同,但动态值名相同(<%=tcount%>,为什么 ...
只看楼主
sylknb
Rank: 4
等 级:贵宾
威 望:14
帖 子:1519
专家分:174
注 册:2006-6-3
结帖率:79.3%
 问题点数:0 回复次数:0 
同时用url传值与表单提交,虽变量不同,但动态值名相同(<%=tcount%>,为什么会显示不同的值?
问题:
同时用url传值与表单提交,虽变量名不同,但动态值名相同(<%=tcount%>,为什么会显示不同的值?请见代码:
用红色标识。书中介绍与实际操作一样都是不同的二个值,一个修改前的值,一个是修改后的值。修改前的值它从何而来呢?

<!--#include file="conn.asp" -->
<!--#include file="yz_mgr/inc/function.asp" -->
<% If Session("User")="" Then Response.Redirect "login.asp" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>飞雪网上购物系统</title>
<link href="inc/main.css" rel="stylesheet" type="text/css">
</head>
<%     id=Request("id")
    If Session("goods_id")="" Then
        Session("goods_id") = id
        If id<>"" Then Session("goods_count") = id&"|1"
    Else
        If InStr(Session("goods_id"),id) = 0 Then
            Session("goods_id") = Session("goods_id") &","& id
            Session("goods_count") = Session("goods_count") &","&id&"|1"
        End If
    End If
   
    If Request("action")="chgcnt" Then
        chgid = Request("chgid")
        num = Request("num")
        tmp_num = Request.Form("count")
        If IsNumerIc(tmp_num)=True Then
            If tmp_num>0 Then num_new = tmp_num Else num_new = 1
        Else
            num_new = 1
        End If                  

        tmp_count = Replace(Session("goods_count"),","&chgid&"|"&num&",", ","&chgid&"|"&num_new&",")
        If tmp_count=Session("goods_count") Then
            tmp_count = Replace(Session("goods_count"),chgid&"|"&num&",", chgid&"|"&num_new&",")
        End If
        If tmp_count=Session("goods_count") Then
            tmp_count = Replace(Session("goods_count"),","&chgid&"|"&num, ","&chgid&"|"&num_new)
        End If
        If tmp_count=Session("goods_count") Then
            tmp_count = Replace(Session("goods_count"),chgid&"|"&num,chgid&"|"&num_new)
        End If
        Session("goods_count") = tmp_count
    ElseIf Request("action")="dgoods" Then
        did = Request("did")
        tmp_goodsid = Replace(Session("goods_id"),","&did&",",",0,")
        tmp_goodscnt = Replace(Session("goods_count"),","&did&"|",",0|")
        
        If tmp_goodsid = Session("goods_id") Then
            tmp_goodsid = Replace(Session("goods_id"),did&",","0,")            
        End If
        If tmp_goodsid = Session("goods_id") Then
            tmp_goodsid = Replace(Session("goods_id"),","&did,",0")            
        End If
        If tmp_goodsid = Session("goods_id") Then
            tmp_goodsid = Replace(Session("goods_id"),did,"0")            
        End If
        If tmp_goodscnt = Session("goods_count") Then
            tmp_goodscnt = Replace(Session("goods_count"),did&"|","0|")
        End If
        Session("goods_count") = tmp_goodscnt        
        Session("goods_id") = tmp_goodsid        
    Elseif Request("action")="clearbuycar" Then
        Session("goods_id") = ""
        Session("goods_count") = ""
        Response.Redirect "buy_car.asp"
    End    If
%>
<body leftmargin="0" topmargin="0">
<table width="900" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td><!--#include file="top.asp" --></td>
  </tr>  
  <tr>
    <td height="40" class="text1">我的购物车</td>
  </tr>
  <tr>
    <td><table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#0080C0">
      <tr>
        <td width="36%" height="30" align="center" bgcolor="#88D9FF">商品名称</td>
        <td width="15%" align="center" bgcolor="#88D9FF">数 量</td>
        <td width="14%" align="center" bgcolor="#88D9FF">价 格</td>
        <td width="13%" align="center" bgcolor="#88D9FF">金 额</td>
        <td width="22%" align="center" bgcolor="#88D9FF">操 作</td>
      </tr>
      <%If Session("goods_id")<>"" Then
            tmp_id = Split(Session("goods_id"),",")
            tmp_count = Split(Session("goods_count"),",")
            For i=0 To Ubound(tmp_id)
                tid = tmp_id(i)
                tmp_total = 0
                tcount = g_TakeOutStr(tmp_count(i),2,"|")   
                Set Rs = Server.CreateObject("ADODB.Recordset")
                Sql = "Select * From [Shop_Goods] Where ID="&tid
                Rs.Open Sql,conn,1,1
                If Not Rs.Eof And Not Rs.Bof Then                    
                    tmp_total = tcount * Rs("SalePrice")
      %>   
      <form name=listFrm action="?action=chgcnt&chgid=<%=Rs("id")%>&num=<%=tcount%>" method=post>修改前
      <tr>
        <td height="25" bgcolor="#FFFFFF">&nbsp;<%=Rs("Name")%></td>
        <td align="center" bgcolor="#FFFFFF"><input name="count" type="text" value="<%=tcount%>" size="4">&nbsp;<input type="image" name="imageField" src="images/car_chg.gif" align="absmiddle">&nbsp;</td>修改后
        <td align="center" bgcolor="#FFFFFF">¥<%=Rs("SalePrice")%></td>
        <td align="center" bgcolor="#FFFFFF">¥<%=tmp_total%></td>
        <td align="center" bgcolor="#FFFFFF"><a href="?action=dgoods&did=<%=Rs("id")%>">删除</a></td>
      </tr>
      </form>
      <%         End If
                  Rs.Close
                  Set Rs=nothing
                total = total + tmp_total
              Next
          Else
      %>
      <tr>
        <td colspan="5" align="center" bgcolor="#FFFFFF" height=50>您还没有购买任何商品!</td>
      </tr>
      <% End If %>
    </table></td>
  </tr>
  <tr>
    <td height="40" align="center"><table width="100%" border="0" cellspacing="1" cellpadding="0">
      <tr>
        <td width="67%"> </td>
        <td width="14%"><a href="?action=clearbuycar"><img src="images/car_clear.gif" width="97" height="23" border="0"></a></td>
        <td width="19%">订单总额:¥<%=total%></td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td height="40" align="center" class="text1"><a href="index.asp"><img src="images/car_buy.gif" width="188" height="38" border="0"></a>&nbsp;&nbsp;&nbsp;<a href="shop_orders.asp"><img src="images/car_order.gif" width="188" height="38" border="0"></a></td>
  </tr>
  <tr>
    <td><!--#include file="bottom.asp" --></td>
  </tr>
</table>
</body>
</html>
搜索更多相关主题的帖子: 动态 传值 表单 tcount 变量 
2010-03-12 15:29



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




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

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