| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1677 人关注过本帖
标题:全选删除问题
只看楼主 加入收藏
peiyanjian
Rank: 1
等 级:新手上路
帖 子:96
专家分:0
注 册:2008-2-29
收藏
 问题点数:0 回复次数:5 
全选删除问题
全选和删除的代码应该怎么写呀?/放到哪里呢??

<!--#include virtual="/admin_qx.asp" -->

<%
set conn=server.createobject("adodb.connection")
DSNtemp = "Driver={Microsoft Access Driver (*.mdb)};"
DSNtemp = DSNtemp & "DBQ=" & server.mappath("date/student.mdb")
conn.open DSNtemp
stext = "select id,xuehao,xingming,zhiwu,

banji,chushengnianyue,minzu,zhengzhimianmao,dangtuanshijian,jiguan,ruwushijian,wenhuachengd

u,lianxidianhua,ruwudiqu,jiatingzhuzhi,youzhengbianma from stu order by banji"
set rs = conn.execute(stext)
if rs.eof then
response.write "database error"
response.end
end if
%>
<html>
<head>
<%
'set conn=server.createobject("adodb.connection")
'conn.open("DRIVER=Driver do Microsoft ACCESS (*.mdb);dbq="&server.mappath("student.mdb"))
set rs=server.createobject("adodb.recordset")
sql="select * from stu"
rs.open sql,conn,3
rs.pagesize=20
if request("page")<>"" then
  epage=cint(request("page"))
   if epage<1 then epage=1
   if epage>rs.pagecount then epage=rs.pagecount
else
epage=1
end if
rs.absolutepage=epage
%>
<title>十五队学员</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style type="text/css">
<!--
a:link {  color: #000000; text-decoration: none}
a:visited {  color: #000000; text-decoration: none}
-->
</style>

</head>

<body bgcolor="#FFFFFF" text="#000000">
<h2 align="center">欢迎来到sfsdfds理系统</h2>
<h4 align="center">可以点击某一行姓名来察看详细信息</h4>
<p><font color="#0066CC">相关操作: <a href="/xy_add.asp">添加学员</a> | <a

href="/students.asp">显示信息</a>
  | <a href="/index.ASP">退出登陆</a></font></p>
<p>
<form name="form1" method="post" action="/ss.asp">
<td> 姓名
  <input name="xingming" type="text" maxlength="10" size="15">
  班级
  <input name="banji" type="text" maxlength="10" size="15">
  <input name="submit" type="submit" value="显示学生">
</td>
</form>
</p>
<hr size=3 noshadow width=150% align=left></hr>
<div align="center">
  <table width="1600" border="1" cellpadding="0" cellspacing="0" bgcolor="#C7E8F8">
    <tr>
     <td height="22"><div align="center">
      <input name="checkbox" type=checkbox id="checkbox" onClick="this.value=check

(this.form.seltyid)" value="全选">
    </div></td>
    
      <td>
        <div align="center"><font color="#FF0000">姓名</font></div>
      </td>
      <td>
        <div align="center">学号</div>
      </td>
      <td>
        <div align="center">职务</div>
      </td>
      <td>
        <div align="center">班级</div>
      </td>
      <td>
        <div align="center">出生年月</div>
      </td>
      <td>
        <div align="center">民族</div>
      </td>
      <td>
        <div align="center">政治面貌</div>
      </td>
      <td>
        <div align="center">党团时间</div>
      </td>
      <td>
        <div align="center">籍贯</div>
      </td>
      <td>
        <div align="center">入学时间</div>
      </td>
      <td>
        <div align="center">文化程度</div>
      </td>
      <td>
        <div align="center">联系电话</div>
      </td>
      <td>
        <div align="center">入学地区</div>
      </td>
      <td>
        <div align="center">家庭地址</div>
      </td>
      <td>
        <div align="center">邮政编码</div>
      </td>
    </tr>
    <%
    Do while not rs.eof
    %>
     <TR>
     <td height="22"><div align="center">
      <input name="seltyid" type="checkbox" id="seltyid" value="<%=rs("id")%>">
    </div></td>
     <TD><div align="center"><a href='/stu_xx.asp?id=<%=rs("id") %>'><%=rs("xingming")

%></a></div></TD>
     <%
     %>
     <td><div align="center">0<%=rs("xuehao") %></div></td><td><div align="center"><%

=rs("zhiwu") %></div></td><td><div align="center"><%=rs("banji") %></div></td><td><div

align="center"><%=rs("chushengnianyue") %></div></td><td><div align="center"><%=rs("minzu")

%></div></td><td><div align="center"><%=rs("zhengzhimianmao") %></div></td><td><div

align="center"><%=rs("dangtuanshijian") %></div></td><td><div align="center"><%=rs

("jiguan") %></div></td><td><div align="center"><%=rs("ruwushijian") %></div></td><td><div

align="center"><%=rs("wenhuachengdu") %></div></td><td><div align="center"><%=rs

("lianxidianhua") %></div></td><td><div align="center"><%=rs("ruwudiqu") %

></div></td><td><div align="center"><%=rs("jiatingzhuzhi") %></div></td><td><div

align="center"><%=rs("youzhengbianma") %></div></td></tr>
    <%
  
     rs.movenext
    Loop
    
     %>
  </table>
<p align="center">
</p>
<p align="center">现在是第<%=epage%>页一共有<%=rs.pagecount%>页

<a href="/students.ASP">首页</a>&nbsp;
<a href="/students.ASP?page=<%=epage-1%>">前一页</a>&nbsp;
<a href="/students.ASP?page=<%=epage+1%>">后一页</a>&nbsp;
<a href="/students.ASP?page=<%=rs.pagecount%>">末页</a></p>

<form name="form2" method="post" action="">

  <span class="STYLE13"> 全选/不选</span>
    <input name="checkbox2" type=checkbox onClick="this.value=check(this.form.seltyid)"

value="全选">
     
   
  <input type="submit" name="Submit4" value="删除" onClick="subdeletetozhan()"

style="width:85;background-color: #FFCC66; color: #000000; border: 1 solid #00CC00">
    <input name="deleteorupdate" type="hidden" id="deleteorupdate">
    <input name="deleteall" type="hidden" id="deleteall">
    <input name="caozuo" type="hidden" id="caozuo">
</form>
  
</div>

<%
rs.close
conn.close
%>
</body>
</html>
 <script language="javascript">

//
function subdeleteforever()
{
    if (window.confirm('真的要永久删除所选学员吗?该操作不可恢复!继续吗?'))
     {
      form2.action="xy_delete_all.asp";
      form2.deleteall.value="deletforever";
       form2.submit();//提交该表单;
     }
   
}
function subdeletetozhan()
{
form2.action="admin_xy_caozuo.asp";
form2.caozuo.value="intozhan";
form2.submit();
}
</script>
<SCRIPT LANGUAGE="JavaScript">

<!--
var checkflag = "false";
function check(field) {
if (checkflag == "false") {
for (i = 0; i < field.length; i++) {
field[i].checked = true;}
checkflag = "true";
return "false"; }
else {
for (i = 0; i < field.length; i++) {
field[i].checked = false; }
checkflag = "false";
return "true"; }
}
 -->
</script>
搜索更多相关主题的帖子: quot Microsoft DSNtemp Driver mdb 
2008-03-28 21:37
jalonlovesja
Rank: 5Rank: 5
来 自:湖南邵阳
等 级:职业侠客
帖 子:292
专家分:371
注 册:2008-2-19
收藏
得分:0 
你写的太复杂了,
下面是全选的代码:
function ok(CheckBox1)
    {
       var GridView = document.getElementById("GridView1");           
        for(var i=1;i<GridView.rows.length-1;i++)
        {
             GridView.rows[i].cells[0].getElementsByTagName("input")[0].checked=CheckBox1.checked;
        }
   }
下面是全选删除的代码:
foreach (GridViewRow i in GridView1.Rows)
        {
            if ((i.FindControl("CheckBox1") as CheckBox).Checked)
            {
                int Ti_id = int.Parse(GridView1.DataKeys[i.RowIndex].Value.ToString());
                if (cf.DeleteColor(Ti_id))
                {
                    ("删除成功!");
                }
                else
                {
                    ("删除失败!");
                }
            }
        }
        ClothColorBind();
2008-03-29 10:53
peiyanjian
Rank: 1
等 级:新手上路
帖 子:96
专家分:0
注 册:2008-2-29
收藏
得分:0 
要加到哪里呀??

上面怎么改动一下呢
2008-03-29 11:09
hmhz
Rank: 7Rank: 7Rank: 7
等 级:贵宾
威 望:30
帖 子:1890
专家分:503
注 册:2006-12-17
收藏
得分:0 
给你个参考
程序代码:
 
<!--#include file="conn.asp"-->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>日志管理</title>
<link href="style.css" type="text/css" rel="stylesheet">
<style type="text/css">body {margin:0;}</style>
<script language="javascript">
function CheckAll(form){
  for (var i=0;i<form.elements.length;i++){
    var e = form.elements[i];
    if (e.name != 'chkall') e.checked = form.chkall.checked; 
   }
  }
</script>
</head>
<%
if request.form("action")="批量删除" then
Ann=request.form("Ann")
if Ann<>"" and not isnull(Ann) then
   conn.execute "delete jilu_log where id in ("&Ann&")"
end if
end if
%>
<body topmargin="1" leftmargin="0" style="overflow-x:hidden; overflow-y:hidden;">
<div align="center">
<table width="98%" cellpadding="0" style="border-collapse:collapse" border="1" bordercolor="#D4D0C8" cellspacing="0">
<tr>
<th width="25%">用户名/内容</th>
<th width="15%">访问页面</th>
<th width="3%">次</th>
<th width="19%">IP</th>
<th width="26%">详细地址</th>
<th width="9%">日期</th>
<th width="2%"></th>
</tr>
<form method="Post">
<%
Set rs= Server.CreateObject("ADODB.Recordset")
rs.open "select * from dbo.jilu_log order by postdate desc",conn,1,1
if rs.eof and rs.bof then
response.write "<tr bgcolor='#FFFFFF' align='center'><td colspan='6'>没有日志</td></tr>"
else
set id=rs("ID")
set usernames=rs("usernames")
set URL=rs("URL")
set cishu=rs("cishu")
set ip=rs("ip")
set guojia=rs("guojia")
set postdate=rs("postdate")
page=request.querystring("page")
if page="" then page=1 end if
  pages = "25"
rs.pagesize = pages
maxpagecount=rs.pagecount
rs.absolutepage = page 
    i=0
pagestart=page-9
pageend=page+9
if pagestart<1 then
pagestart=1
end if
if pageend>maxpagecount then
pageend=maxpagecount
end if
rcount=rs.RecordCount
do while not rs.eof and i<rs.pagesize
%>
<tr bgcolor="#FFFFFF" align="center" onmouseover="this.style.backgroundColor='#E0DFE3';" onmouseout="this.style.backgroundColor='';">
<td align="right"><%=usernames%> </td>
<td align="left" style="font-size:7pt;"> <%=URL%></td>
<td style="font-size:7pt;"><%=cishu%></td>
<td><font color="#FF3333"<%if instr(ip,"|")>0 then%> title="<%=ip%>"<%end if%>><%=split(ip,"|")(0)%></font></td>
<td><font color="#FF3333"><%=guojia%></font></td>
<td style="font-size:7pt;" title="<%=postdate%>"><%=split(postdate," ")(0)%></td>
<td><input type="checkbox" name="Ann" value="<%=cstr(id)%>" style="width:16px; height:16px;" /></td>
</tr>
<%
rs.movenext
i=i+1
loop
rs.close
set rs=nothing
%>
<tr bgcolor="#e7e7e7">
<td colspan="5" align="center"><a href="?page=1"><span style="font-family:Webdings;">7</span></a>
<%
for n=pagestart to pageend
if n=int(page) then
Response.write " <font color=""red""><b>"&n&"</b></font> "
else
response.write " <a href=""?page="&n&""">"&n&"</a> "
end if

 next
%>
<a href="?page=<%=maxpagecount%>"><span style="font-family:Webdings;">8</span></a> 共<font color="red"><%=maxpagecount%></font>页 每页<font color="red"><%=pages%></font>条 共<font color="red"><%=rcount%></font>条
</td>
<td colspan="2" align="right"><input type="submit" name="action" value="批量删除" /> <input type="checkbox" name="chkall" onclick="CheckAll(this.form);" style="width:16px; height:16px;" />
</td>
</tr>
</form>
<%end if%>
</table>
</div>
</body>
</html>
2008-03-29 20:50
peiyanjian
Rank: 1
等 级:新手上路
帖 子:96
专家分:0
注 册:2008-2-29
收藏
得分:0 
谢谢,我好好研究一下吧
2008-03-30 08:34
peiyanjian
Rank: 1
等 级:新手上路
帖 子:96
专家分:0
注 册:2008-2-29
收藏
得分:0 
好像还是不行呀!!全选不了呀!
2008-03-31 21:02
快速回复:全选删除问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.019177 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved