删除选中记录这样做:
1.在每行加一个checkbox,相同命名,值为记录的ID号
<input type='checkbox' name='selAnnounce' value='<%=cstr(rs("photoid"))%>'>
2.做一个删除按钮
<input name="deletephoto" type='submit'>
3.在代码的前面加段用于接收需删除的记录号
''从复选框中读取要删除的照片的序号,以此调用删除函数
if not isempty(request("selAnnounce")) then
idlist=request("selAnnounce")
if instr(idlist,",")>0 then
dim idarr
idArr=split(idlist)
dim id
for i = 0 to ubound(idarr)
id=clng(idarr(i))
call deleteannounce(id)
next
else
call deleteannounce(clng(idlist))
end if
end if
4.做一个删除函数
sub deleteannounce(id)
'再删除照片记录
sql="delete from PHOTOINFO where PHOTOID="&id
conn.execute sql
if err.Number<>0 then
err.clear
response.write "删 除 失 败 !<br>"
else
response.write "操作成功!<br>"
end if
<Form ... Name="frmSel" ID="frmSel">
<%
...
Do While Not Eof
Response.Write "<Input Type='CheckBox' Name='ID" & RS("ID") & "' Value='True'>"
RS.MoveNext
Loop
...
%>
</Form>
<Script Language="VBScript">
Function frmSel_OnSubmit()
If MsgBox("确实要删除选定的记录吗?",36,"询问")=VBNot Then frmSel_OnSubmit=False
End Function
</Script>