求ASP复选框多选删除 失败(缺少对象)原因 单个删除可以
复选框:<inputtype="checkbox"onClick="javascript:rs=document.getElementsByTagName('input'...
复选框:
<input type="checkbox" onClick="javascript:rs=document.getElementsByTagName('input');for(i=0;i<rs.length;i++){if(rs[i].getAttribute('name')=='newsid') rs[i].checked=this.checked;}">
删除代码:
<!--#include file="../conn.asp"-->
<%
newsid=split(request("newsid"),",")
for i=0 to ubound(newsid)
tsql="select * from news where newsid="&newsid(i)&""
rs.open tsql,cn,1,1
if not rs.eof then
cn.execute "delete from news where newsid="&newsid(i)&""
rs.close
set rs=nothing
end if
cn.execute"delete from news where newsid="&newsid(i)&""
next
response.redirect"news_del.asp"
%> 展开
<input type="checkbox" onClick="javascript:rs=document.getElementsByTagName('input');for(i=0;i<rs.length;i++){if(rs[i].getAttribute('name')=='newsid') rs[i].checked=this.checked;}">
删除代码:
<!--#include file="../conn.asp"-->
<%
newsid=split(request("newsid"),",")
for i=0 to ubound(newsid)
tsql="select * from news where newsid="&newsid(i)&""
rs.open tsql,cn,1,1
if not rs.eof then
cn.execute "delete from news where newsid="&newsid(i)&""
rs.close
set rs=nothing
end if
cn.execute"delete from news where newsid="&newsid(i)&""
next
response.redirect"news_del.asp"
%> 展开
2个回答
展开全部
newsid=split(request("newsid"),",")
for i=0 to ubound(newsid)
tsql="select * from news where newsid="&newsid(i)&""
rs.open tsql,cn,1,1
if not rs.eof then
cn.execute "delete from news where newsid="&newsid(i)&""
rs.close
set rs=nothing
end if
cn.execute"delete from news where newsid="&newsid(i)&""
next
改一下
newsid=request("newsid")
if (newsid,",")=0 Then
cn.execute"delete from news where newsid="&newsid
Else
cn.execute"delete from news where newsid IN ("&newsid&")"
End IF
for i=0 to ubound(newsid)
tsql="select * from news where newsid="&newsid(i)&""
rs.open tsql,cn,1,1
if not rs.eof then
cn.execute "delete from news where newsid="&newsid(i)&""
rs.close
set rs=nothing
end if
cn.execute"delete from news where newsid="&newsid(i)&""
next
改一下
newsid=request("newsid")
if (newsid,",")=0 Then
cn.execute"delete from news where newsid="&newsid
Else
cn.execute"delete from news where newsid IN ("&newsid&")"
End IF
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询