ajax+asp无限级分类树型结构(带数据库)(4)


if nDepth>0 then '修改父id孩子数
conn.execute("update ArticleClass set child=child-1 where child>0 and ClassID=" & nParentID)
end if
sql="delete from ArticleClass where ClassID="& nClassID
conn.execute(sql)
End Sub
Public Function FErrStr()
FErrStr=ErrorStr
End Function
End Class
%>
index.asp
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<%
'作者站点:www.guaishi.org
'邮箱:guaishiorg@126.com
'QQ:514777880
Session.CodePage=65001
Response.Charset = "utf-8"
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<style type="text/css">
body{margin:0;padding:0;font-size:12px; background-color:#FFFFFF;}
ul{ list-style-type:none; margin:0 0 0 20px; padding:0;}
li{ white-space:nowrap; padding:0;}
.childdiv{ background:url(images/dot.gif);background-repeat:repeat-y;}
span { cursor:pointer;}
</style>
<script type="text/javascript">
var xmlHttp; //定义一个全局变量
var currentID=1;//设置当前选中ID,如果此ID不存在则会发生js错误
//类别显示主函数
//cid--子类别所在层id
//id --类别id
//pid--[+]和[-]图标id
//fid--类别图标id
function DivDisplay(cid,id,pid,fid)
{
if (GetId(cid).style.display=='') //子类别不显示时图标显示控制
{
GetId(cid).style.display='none';
GetId(pid).src = 'images/closed.gif';
GetId(fid).src = 'images/folder.gif';
}
else //展开子类别时的操作
{
GetId(cid).style.display='';
GetId(pid).src = 'images/opened.gif';
GetId(fid).src = 'images/folderopen.gif';
if (GetId(cid).innerHTML==''||GetId(cid).innerHTML=='正在提交数据...')
{
GetId(cid).innerHTML='';
ShowChild(cid,id); //调用显示子类别函数
}
}
}
//与上一个函数作用相同,只作用在最后一个类别
function DivDisplay2(cid,id,pid,fid)
{
if (GetId(cid).style.display=='')
{
GetId(cid).style.display='none';
GetId(pid).src = 'images/lastclosed.gif';
GetId(fid).src = 'images/folder.gif';
}
else
{
GetId(cid).style.display='';
GetId(pid).src = 'images/lastopen.gif';
GetId(fid).src = 'images/folderopen.gif';
if (GetId(cid).innerHTML==''||GetId(cid).innerHTML=='正在提交数据...')
{
GetId(cid).innerHTML='';
ShowChild(cid,id);
}
}
}
//类别添加函数
//id--类别id
function ClassAdd(id){
if (GetId("p"+id).src.indexOf("last")>0){ //最后一个类别时的添加操作
if (!GetId("p"+id).onclick){
GetId("p"+id).onclick=function (){DivDisplay2("c"+id,id,"p"+id,"f"+id);}; //为[+]和[-]添加单击事件
GetId("s"+id).ondblclick=function (){DivDisplay2("c"+id,id,"p"+id,"f"+id);}; //为显示类别文字的span添加双击事件

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/1996.html