ASP中复选框全选并删除
<!--#includefile="conn.asp"--><%SetRs=Server.CreateObject("ADODB.RecordSet")SqlStr="s...
<!--#include file="conn.asp" -->
<%Set Rs=Server.CreateObject("ADODB.RecordSet")
SqlStr="select top 3 * from db"
Rs.Open SqlStr,conn,1,1
do while not rs.eof %>
<form name="form3" method="post" action="del.asp?id=<%=rs("id")%>">
<table width="406" height="auto" border="1">
<tr>
<td width="317">编号</td>
<td width="105">是否删除</td>
</tr>
<tr>
<td><%response.write rs("name")%></td>
<td>
<!--<form name="form3" method="post" action="deluser.asp?operstep=del">-->
<input type="checkbox" name="delbox" value="<%=rs("id")%>" />
</td>
</tr>
<%rs.movenext
loop%>
</table>
<p>
<label>
<input type="checkbox" name="checkbox" value="checkbox" />
</label>
点击全选
</p>
<p> </p>
<p>
<input type="submit" name="delbn" value="删 除" />
</p>
</form>
我想在用复选框选择的时候传到DEL.asp中能删除数据库中的数据
点击全选那个复选框就能把所有的复选框全都选上
然后点删除按钮能发送到DEL.asp中删除数据
帮忙把del.asp的代码写出来
谢谢 展开
<%Set Rs=Server.CreateObject("ADODB.RecordSet")
SqlStr="select top 3 * from db"
Rs.Open SqlStr,conn,1,1
do while not rs.eof %>
<form name="form3" method="post" action="del.asp?id=<%=rs("id")%>">
<table width="406" height="auto" border="1">
<tr>
<td width="317">编号</td>
<td width="105">是否删除</td>
</tr>
<tr>
<td><%response.write rs("name")%></td>
<td>
<!--<form name="form3" method="post" action="deluser.asp?operstep=del">-->
<input type="checkbox" name="delbox" value="<%=rs("id")%>" />
</td>
</tr>
<%rs.movenext
loop%>
</table>
<p>
<label>
<input type="checkbox" name="checkbox" value="checkbox" />
</label>
点击全选
</p>
<p> </p>
<p>
<input type="submit" name="delbn" value="删 除" />
</p>
</form>
我想在用复选框选择的时候传到DEL.asp中能删除数据库中的数据
点击全选那个复选框就能把所有的复选框全都选上
然后点删除按钮能发送到DEL.asp中删除数据
帮忙把del.asp的代码写出来
谢谢 展开
3个回答
展开全部
显示数据页面:
<%
set rs = server.CreateObject ("Adodb.Recordset")
sql="select top 500 * from 表名 order by 时间 desc"
set rs = conn.Execute (Sql)
%>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
var checkflag = "false";
function check(field) {
if (checkflag == "false") {
for (i = 0; i < field.length; i++) {
field[i].checked = true;}
checkflag = "true";
return "Uncheck All"; }
else {
for (i = 0; i < field.length; i++) {
field[i].checked = false; }
checkflag = "false";
return "Check All"; }
}
// End -->
</script>
<form name="form1" method="post" action="del.asp">
<input type="submit" name="submit" value="删 除" onClick="return(confirm('确实要删除吗?'));">
<table>
<tr>
<td><input type="checkbox" onClick="this.value=check(this.form.id)"></td>
<td>名称</td>
<td>时间</td>
</tr>
<%
for i=1 to 500
if rs.EOF or rs.BOF then exit for
%>
<tr>
<td><input type="checkbox" name="id" value="<%=rs("id")%>"></td>
<td><%=rs("名称")%></td>
<td><%=rs("发布时间")%></td>
</tr>
<%
rs.movenext
next
%>
</table>
</form>
del.asp 页面:
<%
id=request("id")
set rs = server.CreateObject ("Adodb.Recordset")
sql="delete from 表名 where id in("&id&")"
rs.Open sql,conn,1,3
%>
<%
set rs = server.CreateObject ("Adodb.Recordset")
sql="select top 500 * from 表名 order by 时间 desc"
set rs = conn.Execute (Sql)
%>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
var checkflag = "false";
function check(field) {
if (checkflag == "false") {
for (i = 0; i < field.length; i++) {
field[i].checked = true;}
checkflag = "true";
return "Uncheck All"; }
else {
for (i = 0; i < field.length; i++) {
field[i].checked = false; }
checkflag = "false";
return "Check All"; }
}
// End -->
</script>
<form name="form1" method="post" action="del.asp">
<input type="submit" name="submit" value="删 除" onClick="return(confirm('确实要删除吗?'));">
<table>
<tr>
<td><input type="checkbox" onClick="this.value=check(this.form.id)"></td>
<td>名称</td>
<td>时间</td>
</tr>
<%
for i=1 to 500
if rs.EOF or rs.BOF then exit for
%>
<tr>
<td><input type="checkbox" name="id" value="<%=rs("id")%>"></td>
<td><%=rs("名称")%></td>
<td><%=rs("发布时间")%></td>
</tr>
<%
rs.movenext
next
%>
</table>
</form>
del.asp 页面:
<%
id=request("id")
set rs = server.CreateObject ("Adodb.Recordset")
sql="delete from 表名 where id in("&id&")"
rs.Open sql,conn,1,3
%>
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
显示数据页面:
<%
set
rs
=
server.CreateObject
("Adodb.Recordset")
sql="select
top
500
*
from
表名
order
by
时间
desc"
set
rs
=
conn.Execute
(Sql)
%>
<SCRIPT
LANGUAGE="JavaScript">
<!--
Begin
var
checkflag
=
"false";
function
check(field)
{
if
(checkflag
==
"false")
{
for
(i
=
0;
i
<
field.length;
i++)
{
field[i].checked
=
true;}
checkflag
=
"true";
return
"Uncheck
All";
}
else
{
for
(i
=
0;
i
<
field.length;
i++)
{
field[i].checked
=
false;
}
checkflag
=
"false";
return
"Check
All";
}
}
//
End
-->
</script>
<form
name="form1"
method="post"
action="del.asp">
<input
type="submit"
name="submit"
value="删
除"
onClick="return(confirm('确实要删除吗?'));">
<table>
<tr>
<td><input
type="checkbox"
onClick="this.value=check(this.form.id)"></td>
<td>名称</td>
<td>时间</td>
</tr>
<%
for
i=1
to
500
if
rs.EOF
or
rs.BOF
then
exit
for
%>
<tr>
<td><input
type="checkbox"
name="id"
value="<%=rs("id")%>"></td>
<td><%=rs("名称")%></td>
<td><%=rs("发布时间")%></td>
</tr>
<%
rs.movenext
next
%>
</table>
</form>
del.asp
页面:
<%
id=request("id")
set
rs
=
server.CreateObject
("Adodb.Recordset")
sql="delete
from
表名
where
id
in("&id&")"
rs.Open
sql,conn,1,3
%>
<%
set
rs
=
server.CreateObject
("Adodb.Recordset")
sql="select
top
500
*
from
表名
order
by
时间
desc"
set
rs
=
conn.Execute
(Sql)
%>
<SCRIPT
LANGUAGE="JavaScript">
<!--
Begin
var
checkflag
=
"false";
function
check(field)
{
if
(checkflag
==
"false")
{
for
(i
=
0;
i
<
field.length;
i++)
{
field[i].checked
=
true;}
checkflag
=
"true";
return
"Uncheck
All";
}
else
{
for
(i
=
0;
i
<
field.length;
i++)
{
field[i].checked
=
false;
}
checkflag
=
"false";
return
"Check
All";
}
}
//
End
-->
</script>
<form
name="form1"
method="post"
action="del.asp">
<input
type="submit"
name="submit"
value="删
除"
onClick="return(confirm('确实要删除吗?'));">
<table>
<tr>
<td><input
type="checkbox"
onClick="this.value=check(this.form.id)"></td>
<td>名称</td>
<td>时间</td>
</tr>
<%
for
i=1
to
500
if
rs.EOF
or
rs.BOF
then
exit
for
%>
<tr>
<td><input
type="checkbox"
name="id"
value="<%=rs("id")%>"></td>
<td><%=rs("名称")%></td>
<td><%=rs("发布时间")%></td>
</tr>
<%
rs.movenext
next
%>
</table>
</form>
del.asp
页面:
<%
id=request("id")
set
rs
=
server.CreateObject
("Adodb.Recordset")
sql="delete
from
表名
where
id
in("&id&")"
rs.Open
sql,conn,1,3
%>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询