[求助]如此解决,,此种参数传递的问题

jlilo 2005-05-31 07:54:36
最近搞了一个留言板,,,,,出了点问题.

在列表页list.asp,
________________________________________________________
Title | Edit|Del
--------------------------------------------------------


点击Title,会前往详细页面abc.asp通常跟的参数是abc.asp?Id=2之类的

同样的,点击Edit或是Del就会前往,相关页面,,,,,,如edit.asp?Id=2 或是 del.asp?Id=2

但是,,我发现,如果,点击编辑,,更新后前往list.asp的时候,在点击详细相应的链接

怎么就是会变成.....abc.asp?Id=2&Id=2 之类的东西,,,但是,如果改list.asp页面刷新一下,就不会

就是Edit完毕相关数据后,,前往的list.asp的页面,如果有刷新,就不会..出现那种错误..


我是asp的新手,,,还望大家不吝赐教.......
...全文
184 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
hchxxzx 2005-06-22
  • 打赏
  • 举报
回复
更新后前往list.asp的时候,在点击详细相应的链接
------
注意,你在list.asp页面里面,页面上的链接是否有这样的参数
list.asp?id=xx?id=bb
如果有,那么,你在代码里面这样取
id = request("id")的时候,它的值其实就是xx?id=bb,因为两个连续的?号分隔的参数,它会认为是一个.
这是第一个可能.
第二个可能
你在更新页面里面,如果取值是这样取
id=request("id")
而你页面中又放了一个名称为ID的控件,这样取值的时候,也会出现两个ID,一个是form里面传递来的,一个是get页面中的参数id.
你检查一下你的代码.
jlilo 2005-05-31
  • 打赏
  • 举报
回复
<HTML>
<HEAD>
<TITLE><%=title%>>布置作业列表页</TITLE>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<META content="MSHTML 6.00.2800.1491" name=GENERATOR>
<META HTTP-EQUIV="REFRESH" CONTENT="2; URL=Admin_hlist.asp">
<link href="images/style.css" rel="stylesheet" type="text/css">
<SCRIPT language=javascript src="images/link.js"></SCRIPT>
<style type="text/css">
<!--
.style1 {font-family: "宋体"}
-->
</style>
</HEAD>
<BODY leftMargin="0" topmargin="0" >

<TABLE height=22 cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY>
<TR>
<TD id=msviRegionGradient1
style="FILTER: progid:DXImageTransform.Microsoft.Gradient(startColorStr='#4B92D9', endColorStr='#CEDFF6', gradientType='1')"
width="48%"></TD>
<TD id=msviRegionGradient2
style="FILTER: progid:DXImageTransform.Microsoft.Gradient(startColorStr='#CEDFF6', endColorStr='#1E77D3', gradientType='1')"
width="45%"></TD></TR></TBODY></TABLE>
<table width="100%" border="0" cellspacing="0" cellpadding="1">
<tr>
<td width="50%" height="37" style="border-bottom: 1px solid #969696; FILTER: progid:DXImageTransform.Microsoft.Gradient(startColorStr='#3399ff', endColorStr='#ffffff', gradientType='1'"></td>
</tr>
</table>
<TABLE cellSpacing=0 cellPadding=0 width="98%" align=center border=0>
<TBODY>
<TR>
<TD class=topleft1 style1> </TD>
</TR>
</TBODY>
</TABLE>
<TABLE cellSpacing=0 cellPadding=0 width="98%" align=center border=0>
<TBODY>
<TR>
<TD width="98%" height="450" align="left"valign="top"><TABLE width="96%" align=center cellPadding=3 cellSpacing=1 class=tableBorder1>
<TBODY>
<TR>
<TH height=24>..::详细列表::.. </TH>
</TR>
<TR>
<TD class=tableBody2 align=middle height=25> </TD>
</TR>
</TBODY>
</TABLE>

<% If Not RS.EOF Or Not RS.BOF Then %>
<TABLE width="98%" align=center cellPadding=3 cellSpacing=1 class=tableBorder1>
<TBODY>
<TR class="p">
<TD width="7%" height="24" class=TableBody1><img src="images/ico.gif" width="9" height="9"> </TD>
<TD width="40%" class=TableBody1>作业题目</TD>
<TD width="16%" class=TableBody1>布置时间</TD>
<TD width="13%" class=TableBody1>上交时间</TD>
<TD width="13%" class=TableBody1>操作</TD>
</TR>
<%
While ((Repeat1__numRows <> 0) AND (NOT RS.EOF))
%>
<TR>
<TD class=tableBody2 height=25> <span class="TableBody1"><img src="images/ico.gif" width="9" height="9"></span></TD>
<TD class=tableBody2><A HREF="H_detail.asp?<%= Server.HTMLEncode(MM_keepURL) & MM_joinChar(MM_keepURL) & "Id=" & RS.Fields.Item("Id").Value %>"><%=(RS.Fields.Item("h_title").Value)%></A></TD>
<TD class=tableBody2><%=(RS.Fields.Item("h_Time").Value)%></TD>
<TD class=tableBody2><font color="#FF0000"><%=(RS.Fields.Item("h_Ltime").Value)%></font></TD>
<TD class=tableBody2><A HREF="Admin_hledit.asp?<%= Server.HTMLEncode(MM_keepURL) & MM_joinChar(MM_keepURL) & "Id=" & RS.Fields.Item("Id").Value %>">更新</A>|<A HREF="Admin_hldel.asp?<%= Server.HTMLEncode(MM_keepURL) &MM_joinChar(MM_keepURL) & "Id="& RS.Fields.Item("Id").Value %>" onClick="javascript:return confirm('请确认删除操作 ?')">删除</A></TD>
</TR>
<%
Repeat1__index=Repeat1__index+1
Repeat1__numRows=Repeat1__numRows-1
RS.MoveNext()
Wend
%>
</TBODY>
</TABLE>
<% End If ' end Not RS.EOF Or NOT RS.BOF %>
<% If RS.EOF And RS.BOF Then %>
<TABLE width="98%" align=center cellPadding=3 cellSpacing=1 class=tableBorder1>
<TBODY>
<TR>
<TD height="24" class=TableBody1><img src="images/ico.gif" width="9" height="9"> 对不起,暂时没有内容!</TD>
</TR>
</TBODY>
</TABLE>
<% End If ' end RS.EOF And RS.BOF %> <TABLE cellSpacing=0 cellPadding=0 width="98%" align=center border=0>
<TBODY>
<TR>
<TD class=topleft1 style1> </TD>
</TR>
</TBODY>
</TABLE>
<TABLE cellSpacing=0 cellPadding=0 width="98%" align=center border=0>
<TBODY>
<TR>
<TD class=topleft1 style1> </TD>
</TR>
</TBODY>
</TABLE>
<TABLE width="98%" align="center" cellPadding=3 cellSpacing=1 class=tableBorder1>
<TBODY>
<TR>
<TD width="52%" height=25 class=tableBody2> <span class="TableBody1">
<table border="0" width="100%" align="center">
<tr>
<td width="23%" align="center">
<% If MM_offset <> 0 Then %>
<a href="<%=MM_moveFirst%>">第一页</a>
<% End If ' end MM_offset <> 0 %>
</td>
<td width="31%" align="center">
<% If MM_offset <> 0 Then %>
<a href="<%=MM_movePrev%>">前一页</a>
<% End If ' end MM_offset <> 0 %>
</td>
<td width="23%" align="center">
<% If Not MM_atTotal Then %>
<a href="<%=MM_moveNext%>">下一页</a>
<% End If ' end Not MM_atTotal %>
</td>
<td width="23%" align="center">
<% If Not MM_atTotal Then %>
<a href="<%=MM_moveLast%>">最后一页</a>
<% End If ' end Not MM_atTotal %>
</td>
</tr>
</table>
</span></TD>
<TD width="48%" class=tableBody2>  记录 <%=(RS_first)%> 到 <%=(RS_last)%> (总共 <%=(RS_total)%>)</TD>
</TR>
</TBODY>
</TABLE></TD>
</TR></TBODY></TABLE>
<TABLE cellSpacing=0 cellPadding=0 width="100%" align=center border=0>
<TBODY>
<TR>
<TD id=Footer_ads align=middle>
<P> </P></TD></TR>
<TR>
<TD align=middle>
<TABLE align=center>
<TBODY>
</TBODY></TABLE></TD></TR></TBODY></TABLE>
</BODY></HTML>
<%
RS.Close()
Set RS = Nothing
%>
jlilo 2005-05-31
  • 打赏
  • 举报
回复
<%
' *** Move To Record: if we dont know the record count, check the display range

If (MM_rsCount = -1) Then

' walk to the end of the display range for this page
MM_index = MM_offset
While (Not MM_rs.EOF And (MM_size < 0 Or MM_index < MM_offset + MM_size))
MM_rs.MoveNext
MM_index = MM_index + 1
Wend

' if we walked off the end of the recordset, set MM_rsCount and MM_size
If (MM_rs.EOF) Then
MM_rsCount = MM_index
If (MM_size < 0 Or MM_size > MM_rsCount) Then
MM_size = MM_rsCount
End If
End If

' if we walked off the end, set the offset based on page size
If (MM_rs.EOF And Not MM_paramIsDefined) Then
If (MM_offset > MM_rsCount - MM_size Or MM_offset = -1) Then
If ((MM_rsCount Mod MM_size) > 0) Then
MM_offset = MM_rsCount - (MM_rsCount Mod MM_size)
Else
MM_offset = MM_rsCount - MM_size
End If
End If
End If

' reset the cursor to the beginning
If (MM_rs.CursorType > 0) Then
MM_rs.MoveFirst
Else
MM_rs.Requery
End If

' move the cursor to the selected record
MM_index = 0
While (Not MM_rs.EOF And MM_index < MM_offset)
MM_rs.MoveNext
MM_index = MM_index + 1
Wend
End If
%>
<%
' *** Move To Record: update recordset stats

' set the first and last displayed record
RS_first = MM_offset + 1
RS_last = MM_offset + MM_size

If (MM_rsCount <> -1) Then
If (RS_first > MM_rsCount) Then
RS_first = MM_rsCount
End If
If (RS_last > MM_rsCount) Then
RS_last = MM_rsCount
End If
End If

' set the boolean used by hide region to check if we are on the last record
MM_atTotal = (MM_rsCount <> -1 And MM_offset + MM_size >= MM_rsCount)
%>
<%
' *** Go To Record and Move To Record: create strings for maintaining URL and Form parameters

Dim MM_keepNone
Dim MM_keepURL
Dim MM_keepForm
Dim MM_keepBoth

Dim MM_removeList
Dim MM_item
Dim MM_nextItem

' create the list of parameters which should not be maintained
MM_removeList = "&index="
If (MM_paramName <> "") Then
MM_removeList = MM_removeList & "&" & MM_paramName & "="
End If

MM_keepURL=""
MM_keepForm=""
MM_keepBoth=""
MM_keepNone=""

' add the URL parameters to the MM_keepURL string
For Each MM_item In Request.QueryString
MM_nextItem = "&" & MM_item & "="
If (InStr(1,MM_removeList,MM_nextItem,1) = 0) Then
MM_keepURL = MM_keepURL & MM_nextItem & Server.URLencode(Request.QueryString(MM_item))
End If
Next

' add the Form variables to the MM_keepForm string
For Each MM_item In Request.Form
MM_nextItem = "&" & MM_item & "="
If (InStr(1,MM_removeList,MM_nextItem,1) = 0) Then
MM_keepForm = MM_keepForm & MM_nextItem & Server.URLencode(Request.Form(MM_item))
End If
Next

' create the Form + URL string and remove the intial '&' from each of the strings
MM_keepBoth = MM_keepURL & MM_keepForm
If (MM_keepBoth <> "") Then
MM_keepBoth = Right(MM_keepBoth, Len(MM_keepBoth) - 1)
End If
If (MM_keepURL <> "") Then
MM_keepURL = Right(MM_keepURL, Len(MM_keepURL) - 1)
End If
If (MM_keepForm <> "") Then
MM_keepForm = Right(MM_keepForm, Len(MM_keepForm) - 1)
End If

' a utility function used for adding additional parameters to these strings
Function MM_joinChar(firstItem)
If (firstItem <> "") Then
MM_joinChar = "&"
Else
MM_joinChar = ""
End If
End Function
%>
<%
' *** Move To Record: set the strings for the first, last, next, and previous links

Dim MM_keepMove
Dim MM_moveParam
Dim MM_moveFirst
Dim MM_moveLast
Dim MM_moveNext
Dim MM_movePrev

Dim MM_urlStr
Dim MM_paramList
Dim MM_paramIndex
Dim MM_nextParam

MM_keepMove = MM_keepBoth
MM_moveParam = "index"

' if the page has a repeated region, remove 'offset' from the maintained parameters
If (MM_size > 1) Then
MM_moveParam = "offset"
If (MM_keepMove <> "") Then
MM_paramList = Split(MM_keepMove, "&")
MM_keepMove = ""
For MM_paramIndex = 0 To UBound(MM_paramList)
MM_nextParam = Left(MM_paramList(MM_paramIndex), InStr(MM_paramList(MM_paramIndex),"=") - 1)
If (StrComp(MM_nextParam,MM_moveParam,1) <> 0) Then
MM_keepMove = MM_keepMove & "&" & MM_paramList(MM_paramIndex)
End If
Next
If (MM_keepMove <> "") Then
MM_keepMove = Right(MM_keepMove, Len(MM_keepMove) - 1)
End If
End If
End If

' set the strings for the move to links
If (MM_keepMove <> "") Then
MM_keepMove = Server.HTMLEncode(MM_keepMove) & "&"
End If

MM_urlStr = Request.ServerVariables("URL") & "?" & MM_keepMove & MM_moveParam & "="

MM_moveFirst = MM_urlStr & "0"
MM_moveLast = MM_urlStr & "-1"
MM_moveNext = MM_urlStr & CStr(MM_offset + MM_size)
If (MM_offset - MM_size < 0) Then
MM_movePrev = MM_urlStr & "0"
Else
MM_movePrev = MM_urlStr & CStr(MM_offset - MM_size)
End If
%>
jlilo 2005-05-31
  • 打赏
  • 举报
回复
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="Admin_chklogin.asp" -->
<!--#include file="Connections/Conn_site.asp" -->
<%
'------------------
'hlist.asp
'管理布置作业的题目
'-------------
Dim RS
Dim RS_numRows

Set RS = Server.CreateObject("ADODB.Recordset")
RS.ActiveConnection = MM_Conn_site_STRING
RS.Source = "SELECT * FROM hw_lay ORDER BY Id DESC"
RS.CursorType = 0
RS.CursorLocation = 2
RS.LockType = 1
RS.Open()

RS_numRows = 0
%>
<%
Dim Repeat1__numRows
Dim Repeat1__index

Repeat1__numRows = 20
Repeat1__index = 0
RS_numRows = RS_numRows + Repeat1__numRows
%>
<%
' *** Recordset Stats, Move To Record, and Go To Record: declare stats variables

Dim RS_total
Dim RS_first
Dim RS_last

' set the record count
RS_total = RS.RecordCount

' set the number of rows displayed on this page
If (RS_numRows < 0) Then
RS_numRows = RS_total
Elseif (RS_numRows = 0) Then
RS_numRows = 1
End If

' set the first and last displayed record
RS_first = 1
RS_last = RS_first + RS_numRows - 1

' if we have the correct record count, check the other stats
If (RS_total <> -1) Then
If (RS_first > RS_total) Then
RS_first = RS_total
End If
If (RS_last > RS_total) Then
RS_last = RS_total
End If
If (RS_numRows > RS_total) Then
RS_numRows = RS_total
End If
End If
%>
<%
' *** Recordset Stats: if we don't know the record count, manually count them

If (RS_total = -1) Then

' count the total records by iterating through the recordset
RS_total=0
While (Not RS.EOF)
RS_total = RS_total + 1
RS.MoveNext
Wend

' reset the cursor to the beginning
If (RS.CursorType > 0) Then
RS.MoveFirst
Else
RS.Requery
End If

' set the number of rows displayed on this page
If (RS_numRows < 0 Or RS_numRows > RS_total) Then
RS_numRows = RS_total
End If

' set the first and last displayed record
RS_first = 1
RS_last = RS_first + RS_numRows - 1

If (RS_first > RS_total) Then
RS_first = RS_total
End If
If (RS_last > RS_total) Then
RS_last = RS_total
End If

End If
%>
<%
Dim MM_paramName
%>
<%
' *** Move To Record and Go To Record: declare variables

Dim MM_rs
Dim MM_rsCount
Dim MM_size
Dim MM_uniqueCol
Dim MM_offset
Dim MM_atTotal
Dim MM_paramIsDefined

Dim MM_param
Dim MM_index

Set MM_rs = RS
MM_rsCount = RS_total
MM_size = RS_numRows
MM_uniqueCol = ""
MM_paramName = ""
MM_offset = 0
MM_atTotal = false
MM_paramIsDefined = false
If (MM_paramName <> "") Then
MM_paramIsDefined = (Request.QueryString(MM_paramName) <> "")
End If
%>
<%
' *** Move To Record: handle 'index' or 'offset' parameter

if (Not MM_paramIsDefined And MM_rsCount <> 0) then

' use index parameter if defined, otherwise use offset parameter
MM_param = Request.QueryString("index")
If (MM_param = "") Then
MM_param = Request.QueryString("offset")
End If
If (MM_param <> "") Then
MM_offset = Int(MM_param)
End If

' if we have a record count, check if we are past the end of the recordset
If (MM_rsCount <> -1) Then
If (MM_offset >= MM_rsCount Or MM_offset = -1) Then ' past end or move last
If ((MM_rsCount Mod MM_size) > 0) Then ' last page not a full repeat region
MM_offset = MM_rsCount - (MM_rsCount Mod MM_size)
Else
MM_offset = MM_rsCount - MM_size
End If
End If
End If

' move the cursor to the selected record
MM_index = 0
While ((Not MM_rs.EOF) And (MM_index < MM_offset Or MM_offset = -1))
MM_rs.MoveNext
MM_index = MM_index + 1
Wend
If (MM_rs.EOF) Then
MM_offset = MM_index ' set MM_offset to the last possible record
End If

End If
%>
cqhunter 2005-05-31
  • 打赏
  • 举报
回复
代码呢,没有怎么知道你错在什么地方了?
jlilo 2005-05-31
  • 打赏
  • 举报
回复
我是用DW做的,,,,,
jlilo 2005-05-31
  • 打赏
  • 举报
回复
我是让那个list页面,,,一直,刷新,,,,,但是,这个也不是一个很好的办法....
chcpu 2005-05-31
  • 打赏
  • 举报
回复
应该是这样的
不过这也不要紧
因为你的目的就只要取到id,管他多少不要紧
或者判断,有就不添加了
或者你就干脆刷新一次
sdts 2005-05-31
  • 打赏
  • 举报
回复
贴出码来看看啊
unkowme 2005-05-31
  • 打赏
  • 举报
回复
没遇到过!

28,406

社区成员

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

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