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


GetId("p"+id).src = 'images/lastopen.gif';
}
}
else{
if (!GetId("p"+id).onclick){ //不为最后一个类别的添加操作
GetId("p"+id).onclick=function (){DivDisplay("c"+id,id,"p"+id,"f"+id);};
GetId("s"+id).ondblclick=function (){DivDisplay("c"+id,id,"p"+id,"f"+id);};
GetId("p"+id).src = 'images/opened.gif';
}
}
GetId("c"+id).style.display='';
ShowChild("c"+id,id);
}
//类别修改函数
function ClassEdit(id,classname){
GetId("s"+id).innerHTML=classname;
}
//有多个子类别的类别的删除函数
function ClassDel(id){
ShowChild("c"+id,id);
CurrentSelect(currentID,id)
BrowseRight(id);
}
//只有一个子类别的类别的删除函数
function ClassDel1(id){
if (GetId("p"+id).src.indexOf("last")>0){ //当类别是当前类别的最后一个类别时
GetId("p"+id).style.cursor="cursor"; //设置图标的鼠标经过样式
GetId("p"+id).onclick=function (){}; //因为只有一个子类别删除后就不再有子类别,故将图标单击事件修改为空函数
GetId("s"+id).ondblclick=function (){}; //同上
GetId("p"+id).src = 'images/lastnochild.gif'; //图标设置
}
else{
GetId("p"+id).style.cursor="cursor"; //非最后一个类别的删除操作
GetId("p"+id).onclick=function (){};
GetId("s"+id).ondblclick=function (){};
GetId("p"+id).src = 'images/nofollow2.gif'; //这里的图标设置与前面不一样
}
ShowChild("c"+id,id);
CurrentSelect(currentID,id);
BrowseRight(id);
}
//向右边框架传递参数
function BrowseRight(id){
CurrentSelect(currentID,id);
top.ContentFrame.location="../ArticleMain.asp?ClassID="+ id;
}
//设置类别选中状态的函数
function CurrentSelect(oldid,newid){
currentID=newid;
document.getElementById("s"+oldid).style.backgroundColor="white";
document.getElementById("s"+currentID).style.backgroundColor="#C0C0E9";
}
//创建XMLHttpRequest对象
function CreateXMLHttpRequest()
{
if (window.ActiveXObject)
{
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
else
{
xmlHttp = new XMLHttpRequest();
}
}
//Ajax处理函数
//id,层id
//rid,数据在表中的id
function ShowChild(cid,id)
{
CreateXMLHttpRequest();
if(xmlHttp)
{
xmlHttp.open('POST','child.asp',true);
xmlHttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
var SendData = 'id='+id;
xmlHttp.send(SendData);
xmlHttp.onreadystatechange=function()
{
if(xmlHttp.readyState==4)
{
if(xmlHttp.status==200)
{
GetId(cid).innerHTML = xmlHttp.responseText;
}
else
{
GetId(cid).innerHTML='出错:'+xmlHttp.statusText;
}
}
else
{
GetId(cid).innerHTML="正在提交数据...";
}
}
}
else
{
GetId(cid).innerHTML='抱歉,您的浏览器不支持XMLHttpRequest,请使用IE6以上版本!';
}
}
//取得页面对象
//id,层id

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

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