'选择图片代码:index.asp <script language="javascript"> function del() { if (confirm ("确定要删除吗?")) {window.location.href="index.asp?action=del"} else return false; } function CheckAll(form1){for (var i=0;i<form1.elements.length;i++){var e = form1.elements[i];if (e.name != 'chkall')e.checked = form1.chkall.checked;}} </script>
<input name="check" type="checkbox" id="check" value="<%=(rs.Fields.Item("id").Value)%>" /> <input type="checkbox" name="chkall" onclick="CheckAll(this.form)" /> 全选
'删除图片代码:Del.asp <% if request("check")="" then response.write"<script>alert('请选择删除项目!');location.href='index.asp';</script>" else if(request("check") <> "") then Command1__ddd = request("check") Set Rs=Server.CreateObject("ADODB.Recordset") Rs.Open"Select * from pic where id in ("&Command1__ddd&")",conn,1,3 Set Fso = Server.CreateObject("Scripting.FilesystemObject") Do While Not Rs.eof imgpathx = Server.MapPath(Rs("img"))'获取图片实际路径 if fso.fileexists(imgpathx)= true Then'图片存在时删图片 Fso.deletefile (imgpathx) End If rs.delete rs.update Rs.MoveNext Loop set Command2 = Server.CreateObject("ADODB.Command") Command2.ActiveConnection =conn Command2.CommandText = "delete from pic where id in ("& Replace(Command1__ddd, "'", "''") &")" Command2.CommandType = 1 Command2.CommandTimeout = 0 Command2.Prepared = true Command2.Execute() response.Redirect("index.asp") end if end If %> |