首先用代码
<a href="editNews.asp?id=<%=rswm("id")%>">编辑</a>
这样就把id传到editNews.asp页面
然后在editNews.asp页面用
newsid=request("id")
接受到这个值
在学习.net时页面传值用了好长时间才明白
现在学习ASP方便了很多。
<!
DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
>
<!--
#include file="Config/WebConfig.asp"
-->
<
html
xmlns
="http://www.w3.org/1999/xhtml"
>
<
head
>
<
title
>
asp版新闻发布
</
title
>
</
head
>
<
body
>
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
<%
![](/Images/OutliningIndicators/InBlock.gif)
if request.QueryString("action")="del" then
dim ok
dim ok2
ok=request.Form("id")
ok2=split(ok,", ")
response.Write(ok2(i))
For i = 0 To UBound(ok2)
response.Write("您选的第"& i+1 &"个ID:" & ok2(i)& "<br />")
conn.execute("DELETE FROM [dbh171001].[h171001].[PowerSite_User_Disp] where userid=" & ok2(i))
Next
response.Redirect("showNews.asp?action=delok")
set conn=nothing
![](/Images/OutliningIndicators/InBlock.gif)
end if
sqlwm = "SELECT * FROM PowerSite_User_Disp"
set rswm= server.CreateObject("adodb.recordset")
rewm=nothing
rswm.open sqlwm,conn,1,1
%>
<
form
action
="shownews.asp?action=del"
method
="post"
name
="f"
>
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
<
a
href
="addnews.asp"
target
="_blank"
>
添加新闻
</
a
>
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
<
INPUT
type
="submit"
value
="删除"
>
<%
if request.QueryString("action")="delok" then response.Write("<font color=red>删除成功!</font>")
%>
<
br
/>
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
<%
do while not rswm.eof
%>
<%
=
rswm(
"
UserID
"
)
%>
<%
=
rswm(
"
msn
"
)
%>
<%
=
rswm(
"
qq
"
)
%>
<
a
href
="editNews.asp?id=<%=rswm("
userid")%
>
">编辑
</
a
>
<
input
type
="checkbox"
name
="id"
value
="<%=rswm("
UserID")%
>
" >
![](/Images/OutliningIndicators/None.gif)
<
br
/>
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
<%
rswm.movenext
loop
rewm=nothing
%>
</
form
>
![](/Images/OutliningIndicators/None.gif)
</
body
>
<%
@LANGUAGE="VBSCRIPT" CODEPAGE="936"
%>
<!--
#include file="Config/WebConfig.asp"
-->
<!
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
>
asp版新闻发布—编辑
</
title
>
</
head
>
![](/Images/OutliningIndicators/None.gif)
<
body
>
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
<%
newsid=request("id")
sqlwm = "SELECT * FROM PowerSite_User_Disp where userid="+newsid
set rswm= server.CreateObject("adodb.recordset")
rswm.open sqlwm,conn,1,1
%>
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
<
SCRIPT
LANGUAGE
="JavaScript"
>
function checkadd()
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](/Images/OutliningIndicators/ContractedSubBlock.gif)
{
if (document.postart.dtitle.value.length<1)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
alert("请您填写信息标题!");
document.postart.dtitle.focus();
return false;
}
if (document.postart.dtext.value.length<1)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
alert("请您填写信息内容!");
document.postart.dtext.focus();
return false;
}
if (document.postart.dtext.value.length>120)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
alert("请把信息内容的字数控制在120以内!");
document.postart.dtext.focus();
return false;
}
}
</
SCRIPT
>
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
<
SCRIPT
LANGUAGE
="JavaScript"
>
maxLen = 120;
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
function checkMaxInput(form)
{
if (form.dtext.value.length > maxLen)
form.remLen.value = 0;
else form.remLen.value = maxLen - form.dtext.value.length;
}
</
script
>
<
form
action
=""
method
="post"
name
="form"
onSubmit
="return checkadd()"
>
<
table
>
<
tr
bgcolor
="#FFFFFF"
>
<
td
width
="15%"
height
="26"
align
="right"
>
新闻标题:
</
td
>
<
td
width
="65%"
height
="26"
><
input
type
="text"
name
="dtitle"
size
="70%"
maxlength
="20"
value
="<%=rswm("
msn") %
>
">
<
font
color
="#FF0000"
>
* 20字以内
</
font
></
td
>
</
tr
>
<
tr
bgcolor
="#FFFFFF"
>
<
td
align
="right"
>
新闻内容:
</
td
>
<
td
><
textarea
rows
="6"
name
="dtext"
cols
="90%"
onKeyDown
="checkMaxInput(this.form)"
onKeyUp
="checkMaxInput(this.form)"
class
="txtl"
maxlength
="120"
>
<%
=
rswm(
"
QQ
"
)
%>
</
textarea
>
<
font
color
="#FF0000"
>
*
120字以内
</
font
></
td
>
</
tr
>
<
tr
>
<
td
height
="26"
align
="right"
bgcolor
="#FFFFFF"
>
</
td
>
<
td
height
="26"
bgcolor
="#FFFFFF"
><
font
color
="#FF0000"
>
目前还可以写
<
input
readonly type
=text
name
=remLen
size
=2
maxlength
=2
value
="120"
style
="border: 1 solid #888888"
>
个字
</
font
></
td
>
</
tr
>
<
tr
>
<
td
><
input
type
="submit"
value
="更新"
name
="submit"
></
td
>
</
tr
>
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
<%
dim newscontent,newstitle
newscontent=replace(trim(Request.Form("dtext")),"'","‘")
newstitle=replace(trim(Request.Form("dtitle")),"'","‘")
if(newscontent <>"") then
![](/Images/OutliningIndicators/InBlock.gif)
Sql="UPDATE [dbh171001].[h171001].[PowerSite_User_Disp] SET [MSN] = '"&newstitle&"',QQ='"&newscontent&"' where userid="
![](/Images/OutliningIndicators/InBlock.gif)
Set Rs=Conn.execute(Sql)
Response.Write ("<script>alert('恭喜您!更新成功!');window.close();</script>")
end if
%>
</
table
>
</
form
>
</
body
>
</
html
>
转载于:https://www.cnblogs.com/gengxiaochao/archive/2007/10/29/942076.html