关于“asp网站一次性提交删除多条记录的程序设计”
一、javascript标签设计,目的为判断一次选择了多少条记录以及设计delnews的action
//cdel()
function cdel()
{
if(CheckSelect()==false)
{
return false;
}
if (confirm("你确定要删除这些文章吗?不可恢复!")){
document.delnews.action.value = "del";
document.delnews.submit();
}
}
//SelectCheckBox()
function SelectCheckBox()
{
for(i=0;i
if(document.all("selectCheck").checked == true)
{
document.delnews.elements[i].checked = true;
}
else
{
document.delnews.elements[i].checked = false;
}
}
}
二、循环列出记录数,循环程序省略。
三、一次删除多条记录程序,用循环的办法,先把选中的记录分割成数组,之后用循环把它搞定。
<%=oRs("D_Title")%> 全选
<%
strIdList = GetSafeStr(Trim(Request.Form("NewsID")))
If Not IsEmpty(strIdList) Then
arrIdList = Split(strIdList,",")
For i = 0 To UBound(arrIdList)
iId = Clng(arrIdList(i))
oConn.Execute("DELETE FROM guestbook WHERE id="&iId&"")
Next
alert("信息删除成功")
Else
alert("请至少选择一条信息记录!)
End I
%>