分页显示中多选删除数据的问题

firefly_xu 2003-10-17 09:38:22
<%
分页显示程序
...
<%do while not rst.eof and rowcount>0%>
...
<td width="6%" align="center"><font font face="宋体" size="2" color="#000080"><%=rst("cname")%></td>
<td width="6%" align="center" ><font font face="宋体" size="2" color="#000080"><input type="checkbox" name="delok" value="<%=rst("ID")%>"></a></td>
...
<%
rowcount=rowcount-1
rst.movenext
loop
%>
<input type="button" value="删除选定记录" name="butt2">


我希望通过这个程序实现:在显示的记录中选择要删除的记录(多选),
点击“删除选定记录”按钮,将这些选定的记录一并删除。
我不知道如何实现这些功能:这些checkbox的value怎么提交给删除程序。
删除程序怎么确定要删除的checkbox value的个数、、、
请高手指导,满意必给分,谢谢!
...全文
142 18 打赏 收藏 转发到动态 举报
写回复
用AI写文章
18 条回复
切换为时间正序
请发表友善的回复…
发表回复
Miriamy 2003-10-19
  • 打赏
  • 举报
回复
//function.js

function CheckAll(){
var i=0;
var arrayCheckbox = document.getElementsByName("checkbox")
for(i=0;i<arrayCheckbox.length;i++){
arrayCheckbox[i].checked=true;
}
}

function CheckOther(){
var i=0;
var arrayCheckbox = document.getElementsByName("checkbox")
for(i=0;i<arrayCheckbox.length;i++){
arrayCheckbox[i].checked=false;
}
}
///////////////////////////////////////////
提交页

html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>

<body bgcolor="#FFFFFF" text="#000000">
<form>
<input type="checkbox" name="checkbox" value="c1">
<input type="checkbox" name="checkbox" value=" c2">
<input type="button" name="Button" value="全选" onClick="CheckAll();">
<input type="button" name="Button" value="反选" onClick="CheckOther();">
<input type="submit" name="Button" value="提交">
</form>
</body>
</html>
///////////////////////////////////////////////////////////
执行页

conn.execute("delete from 表 where id in ("& request.form("checkbox")&")")

imlogo 2003-10-17
  • 打赏
  • 举报
回复
我也想知道如何删除跨页信息

就是说被删除的信息可能分处于多个页面中,楼上说用客户端脚本的朋友,能不能贴一点代码?
lovehwq21 2003-10-17
  • 打赏
  • 举报
回复
晕,给了这么多还不够啊,不试不行啊,楼主
firefly_xu 2003-10-17
  • 打赏
  • 举报
回复
To:wanghui0380(放歌) ( )
是不是把
...
2.dellist=replace("request("xxx"),", ",",")
3.conn.execute("delete from art where id in dellist")
...
写入另一个ASP程序,比方“del.asp“里
然后本分页程序的
<input type="button" value="删除选定记录" name="butt2"
onclick=formcompany.method="post":formcompany.action="del.asp":formcompany.submit
language="vbscript">
这样进行提交呢?
不能用“<form name="formdel" method="post" action="del.asp">”
因为分页程序的此处要提交分页的信息。
firefly_xu 2003-10-17
  • 打赏
  • 举报
回复
To:socamp(camp-lai)
如果是后者,定义Session数组时你怎么确定数组的个数呢?
  • 打赏
  • 举报
回复
是只删除一页内的多选记录还是用户在浏览很多页后一并提交然后删除多页的多选记录?
如果是后者,建议用两Session数组来保存,一个保存数据,另一个保存顺序(如:1,3,5)。
avonqin 2003-10-17
  • 打赏
  • 举报
回复
晕~~~
tigerwen01(小虎)(编程艺术化) 的就可以啦,你还有什么问题?
wanghui0380 2003-10-17
  • 打赏
  • 举报
回复
一个就可以了
firefly_xu 2003-10-17
  • 打赏
  • 举报
回复
To:wanghui0380(放歌) ( )
我的分页程序,每页显示10条记录
2.dellist=replace("request("xxx"),", ",",")语句的", "部分是不是也要10个呢?
firefly_xu 2003-10-17
  • 打赏
  • 举报
回复
to:lp1983(拼) ( )
确实只能删除本页显示的数据。
可我不知道怎么使用客户端的脚本分页显示数据库内的数据。请指教。
firefly_xu 2003-10-17
  • 打赏
  • 举报
回复
是不是把
...
2.dellist=replace("request("xxx"),", ",",")
3.conn.execute("delete from art where id in dellist")
...
写入另一个ASP程序,比方“del.asp“里
然后本分页程序的
<input type="button" value="删除选定记录" name="butt2"
onclick=formcompany.method="post":formcompany.action="del.asp":formcompany.submit
language="vbscript">
这样进行提交呢?
tigerwen01 2003-10-17
  • 打赏
  • 举报
回复
使用For Each ... in ...循环,下面给出一个例程:
seldel.asp:
<form method="post" action="del.asp">
<%do while not rs.eof%>
<tr>
<td>
<input type=checkbox name="xxx" value=<%=rs("id")%>><%=rs("field")%>
</td>
</tr>
<%
rs.MoveNext
loop
%>
<input type=submit name=s1 value=删除>
</form>
----------------------
del.asp:
<%
...
dim articalID,strArticalID
strArticalID=""
For Each strArticalID in Request.Form("xxx")
articalID=Cint(strArticalID)
if strArticalID <> "" then
Conn.execute "delete from table where id="&Cstr(articalID)
strArticalID=""
end if
next
Response.write "数据删除成功!"
%>
lp1983 2003-10-17
  • 打赏
  • 举报
回复
不会的,名字一样会被认为成一个数组的
ttt2 2003-10-17
  • 打赏
  • 举报
回复
<html>

<head>
<meta http-equiv="Content-Language" content="zh-cn">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>New Page 1</title>
<link rel="stylesheet" type="text/css" href="../../main.css">
</head>
<!-- #include file="../../net.asp" -->
<!-- #include file="../../bl.asp" -->
<!-- #include file="../../check.asp" -->

<%
if checkqx(session("sofficeqx"),13)=false then
response.write "您没有权限!"
response.end
end if

%>
<%zgqx=checkqx(session("sofficeqx"),13)%>
<body>
<script language="javascript">
function check()
{
if (confirm('<%=msgdelok%>'))
{
document.form1.submit()
}

}
</script>
<%
delid=request.form("delid")
if delid="" then

gjz=request.querystring("gjz")

p=request.querystring("p")
if p="" then p=1
set rs=server.createobject("adodb.recordset")
rs.pagesize=session("sofficesize")
if gjz="" then
rs.open "select * from work where mk=2 order by id desc",cn,1,3
else
rs.open "select * from work where mk=2 and title like '%"&gjz&"%' order by id desc",cn,1,3
end if
%>
<p>当前位置:标准规范   当前共有<b><%=rs.recordcount%></b>篇文档   </p> <form method="get" action="doclist.asp" name="form2">
<table border="0" width="100%">
<tr>
<td width="33%">
<input type="button" value="增加记录" class=in02 onclick="location.href='adddoc.asp'" <%if zgqx=false then%>disabled<%end if%>>
<input type="button" value="删除记录" class=in02 onclick="check()" <%if zgqx=false then%>disabled<%end if%>>
</td>
<td width="67%">
<p>关键字 <input type="text" name="gjz" size="20" class="in01" value="<%=gjz%>"> <input type="submit" value="查找" name="B1" class="in02"></p>
</td>
</tr>
</table> </form>
<form name="form1" method="post" action="doclist.asp">
<table border="1" width="100%" bordercolordark="#FFFFFF" cellspacing="0" cellpadding="0" bordercolorlight="#C0C0C0" frame="box">
<tr>
<td width="10%" height="18" bgcolor="#F2F2F2">
<p align="center">记录编号</td>
<td width="21%" height="18" bgcolor="#F2F2F2">
文号</td>
<td width="35%" height="18" bgcolor="#F2F2F2">标准规范名称</td>
<td width="17%" height="18" bgcolor="#F2F2F2" align="center">查看</td>
<td width="17%" height="18" bgcolor="#F2F2F2" align="center">时间</td>
</tr>
<%
if not rs.eof then
i=0
rs.absolutepage=cint(p)
end if
while not rs.eof and i<rs.pagesize%>
<tr onmouseover="this.style.backgroundColor='#F2F2F2';this.style.cursor='hand'" onmouseout="this.style.backgroundColor='#ffffff'">
<td width="10%" height="19"><input type="checkbox" name="delid" value="<%=rs("id")%>"><%=rs("id")%></td>
<td width="21%" height="19"> <%=rs("wh")%></td>
<td width="35%" height="19"> <a href="modidoc.asp?id=<%=rs("id")%>"><%=rs("title")%></a></td>
<td width="17%" height="19">
<p align="center"><a href="look.asp?id=<%=rs("id")%>">查看</a></p>
</td>
<td width="17%" height="19"> <%=rs("adate")%></td>
</tr>
<%
i=i+1
rs.movenext
wend%>
</table><Br>  共有<%=rs.recordcount%>条记录    每页显示<%=rs.pagesize%>条     <% if rs.pagecount=0 then%>0<%else%><%=p%><%end if%> / <%=rs.pagecount%>   <%
if rs.recordcount=0 then
else
%><input type="button" value="首页" onclick="location.href='doclist.asp?gjz=<%=gjz%>&bmid=<%=bmid%>&bmname=<%=bmname%>'" class=in02>
<%if cint(p)>1 then%>
<input type="button" value="上页" onclick="location.href='doclist.asp?p=<%=p-1%>&gjz=<%=gjz%>&bmid=<%=bmid%>&bmname=<%=bmname%>'" class=in02>

<%end if%>
<% if cint(p)-rs.pagecount=0 then%>
<%else%>
<input type="button" value="下页" onclick="location.href='doclist.asp?p=<%=p+1%>&gjz=<%=gjz%>&bmid=<%=bmid%>&bmname=<%=bmname%>'" class=in02>
<%end if%>
<input type="button" value="尾页" onclick="location.href='doclist.asp?p=<%=rs.pagecount%>&gjz=<%=gjz%>&bmid=<%=bmid%>&bmname=<%=bmname%>'" class=in02>
<%end if%>
<input type="hidden" value="<%=p%>" name="p">
</form>
<%
else
p=request.form("p")
sql="delete from work where id in ("&delid&")"
'response.write sql
cn.execute sql
response.redirect "doclist.asp?p="&p
end if
%>
</body>

</html>
lp1983 2003-10-17
  • 打赏
  • 举报
回复
如果你使用的是服务器端的分页的话,只能删除当前页的选中的内容,因为你选择其他页时,页面会提交,这样你选中的内容在下页提交时已经不存在了,建议使用客户端的脚本分页,这样不会提交,如果你只是想要当前页的删除,那么直接在处理页面request("delok")不就可以了吗
firefly_xu 2003-10-17
  • 打赏
  • 举报
回复
这里所有checkbox名都为"delok"对程序不会有影响吗?
wanghui0380 2003-10-17
  • 打赏
  • 举报
回复
1.给你的checkbox名成同一个名字如:xxx
2.dellist=replace("request("xxx"),", ",",")
3.conn.execute("delete from art where id in dellist")
这样就可以了

注:同名的checkbox传的植类似如下格式12213, 21331, 123123, 1344他是以", "为分隔的,注意逗号后还有一个空格
mjwgtm 2003-10-17
  • 打赏
  • 举报
回复
<%
for i=1 to request.form("idd").count
conn.execute("delete from art where id="&request.form("idd")(i)) //idd为checkbox名
next
%>
里面暂时只有90个列子 1.Cookie 2.Cookie可存取路径的设置 3.Cookie有效时间的设置 4.Cookie的应用 - 网上考试 5.IO流 6.session时间与编号 7.url重组 8.下拉列表框 9.下拉菜单联动 10.使用Beans 11.修改数据 12.写内容到文件 13.函数中投掷异常 14.分行写入数据 15.分页显示 16.分页显示调查问卷 17.删除数据 18.判断是否空白文件 19.利用absolute方法设置记录指标所指向的记录 20.利用applet载入applet 21.单选型列表框] 22.单选择按钮 23.参数式查询 24.发E-mail 25.发送邮件 26.取得当前的磁盘路径 27.取得数据库中各栏名称 28.取得文件属性 29.取得目录中的文件 30.图形计数器 31.多选型列表框 32.存取application数据 33.学生成绩单 34.将数据写入文件 35.应用cookie的猜数字 36.应用session的网上测试 37.建立错误页 38.指定用户计数器 39.数据完整查询 40.数据库链接的建立与关闭 41.整笔记录的修改 42.文件的建立与删除 43.文字型计数器 44.显示时间和年月日 45.显示目录中内容 46.月历 47.有效时间的设置与取得 48.检查框的使用 49.汉字处理 50.注册确认 51.添加数据 52.添加表单中数据 53.游戏软件购物中心 54.游戏:二十一点 55.猜数字游戏 56.用Bean传递数据 57.用Bean链接数据库 58.用plugin加载Applet 59.用通配符查询 60.略过字节不读取 61.目录的建立与删除 62.真正的计算器 63.管理Session变量 64.网上测验 65.网络订餐服务 66.群组检查框的使用 67.聊天室 68.自行投掷异常 69.色彩变换 70.获得客户端浏览器信息 71.计数器 72.计算器 73.记事本 74.记录数与记录指针位置 75.设置光标位置 76.设置显示页 77.设置页面属性 78.读取整行字符 79.读取文件中的字符 80.读取文件内容 81.读文件内容 82.追加内容到文件 83.逆序取得数据 84.选择钮的数据检查javascript 85.逐渐显示文字 86.通讯录 87.错误检测 88.随机大小的文字 89.顺序取得数据 90.高级搜索
一、表头表尾 1、自定义多行表头,列合并,行合并 2、删除表身指定列、行 3、固定表头,向下拉动滚动条时,表头固定不动 4、表脚行统计,总计、平均值 二、导入导出 1、导出Excel,Word 2、导入Excel 三、多层嵌套 1、在父GridView中的编辑模板中嵌套一个子GridView 2、三层GridView嵌套 四、分页排序 1、分页 2、列排序,点击列升序、降序排序 五、结合控件 1、CheckBox控件,多选、全选 2、DropDownList控件 3、隐藏控件,当选择处理状态选中备注时,隐藏textbox显示 4、radio控件,选中获取GridView表主键 5、GridView中DropDownList绑定数据,直接绑定显示,无需点击编辑按纽。 6、JavaScript操作checbox实现全选,多选 六、设置属性 1、JavaScript设置GridView行的背景颜色,单偶行的背景颜色,鼠标停留行背景,鼠标选中时的行背景 2、GridView的JavaScript中的行单击,双击、删除提示框、快捷键事件 3、GridView设置属性,单元格文本颜色,单元格背景颜色,表中增加空行 七、无代码 GridView排序、发送邮件、点击行查看详情,内容过长截取 八、选增删改 1、GridView自带的选中、编辑、删除,即CommandField 2、GridView添加记录,在GridView表脚添加控件,用添加记录 3、更新所有记录,GridView直接绑定控件,然后更新 九、主键索引 根据主键多条记录删除,单条记录删除

28,390

社区成员

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

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