首先用代码
<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>    


        
<% 

    
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

    
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" >


<href="addnews.asp" target="_blank">添加新闻</a>&nbsp;&nbsp;
            
<INPUT type="submit" value="删除"><%if request.QueryString("action")="delok" then response.Write("<font color=red>删除成功!</font>"%>
            
<br />
            
<%do while not rswm.eof  %>
             
            
<%=rswm("UserID")%>&nbsp;&nbsp;<%=rswm("msn")%>&nbsp;<%=rswm("qq")%> 
            
            
<href="editNews.asp?id=<%=rswm("userid")%>">编辑</a>
            
<input type="checkbox" name="id" value="<%=rswm("UserID")%>" >

            
<br />
            
<%rswm.movenext    
            
loop 
            
            rewm
=nothing
            
%>
            
</form>     
        

    
</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>

<body>
<%
newsid
=request("id")
    sqlwm 
= "SELECT * FROM PowerSite_User_Disp where userid="+newsid
    
set rswm= server.CreateObject("adodb.recordset")
    rswm.open sqlwm,conn,
1,1
%>
<SCRIPT LANGUAGE="JavaScript">
function checkadd()
{   
  
if (document.postart.dtitle.value.length<1)
    
{
        alert(
"请您填写信息标题!");
        document.postart.dtitle.focus();
        
return false;
    }

    
if (document.postart.dtext.value.length<1)
    
{
        alert(
"请您填写信息内容!");
        document.postart.dtext.focus();
        
return false;
    }

        
if (document.postart.dtext.value.length>120)
    
{
        alert(
"请把信息内容的字数控制在120以内!");
        document.postart.dtext.focus();
        
return false;
    }

}

</SCRIPT>
<SCRIPT LANGUAGE="JavaScript">      
maxLen 
= 120;
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">*&nbsp;120字以内</font></td>
    
</tr>
    
<tr>
      
<td height="26" align="right" bgcolor="#FFFFFF">&nbsp;</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>
    
    
<%
    
dim newscontent,newstitle
newscontent
=replace(trim(Request.Form("dtext")),"'","")
newstitle
=replace(trim(Request.Form("dtitle")),"'","")
if(newscontent <>""then

Sql
="UPDATE [dbh171001].[h171001].[PowerSite_User_Disp] SET [MSN] = '"&newstitle&"',QQ='"&newscontent&"' where userid="

        
Set Rs=Conn.execute(Sql)
        
Response.Write (
"<script>alert('恭喜您!更新成功!');window.close();</script>")
end if
%>
    
  
</table>
</form>
</body>
</html>
posted on 2007-10-29 21:21  超少  阅读(593)  评论(0编辑  收藏  举报