var a=new dtree('a','main')
a.addfolder('学生管理')
 a.addfolder('系统管理')
  a.addnode('登录','oldlogin1.html')
  a.addnode('注册','zhuce1.html')
  a.addnode('查看公告','listnotice.asp')
a.endfolder()
a.addfolder('课程学习')
  a.addnode('语文')
  a.addnode('数学')
  a.addnode('英语')
  a.addnode('文综')
  a.addnode('理综')
a.endfolder()
a.addfolder('留言版管理')
  a.addnode('管理中心','admin.asp')
a.endfolder()
a.addfolder('下载管理')
a.endfolder()
a.addnode('退出系统','logout.asp')
a.endfolder()
a.init()
a.expandall(true)

解决方案 »

  1.   

    怎么解释?
    需要dtree.js的格式.
      

  2.   

    是啊,我从书上找来一个,可总是报错,说是19行,83字符,未结束的字符传.帮忙给看看哪里有错啊?
    var imgpath=["img/plus.gif","img/minus.gif","img/dot.gif"]
    function dtree(obj,target,check)
    {
     this.obj=obj
     this.target=target
     this.child=0
     this.node=0
     this.icon=[]
     this.showcheck=check
     this.html="<table id='deeptree' onselectstart='return false' cellspacing=0 cellpadding=0 border=0>"
     for(i=0;i<imgpath.length;i++)
      {
       var tem=new image()
       this.icon[i]=tem.src=imgpath[i]}
    }
    dtree.prototype.addfolder=function(txt,link,show)
    {
      this.msg[this.node]=[txt,link?link:'']
      this.html+="<tr><td class='node'><img src='"+(show?this.icon[1]:this.icon[0])+"'
      id='img"+this.child+"' border=0 align='absmiddle' onclick='"+this.obj+".expand("+this.child+")'>
      <input type='checkbox' name='treefolder' onclick='"+this.obj+".checkall(this,"+this.child+")' style='display:"+(this.showcheck?'':'none')+"'>
      <span onmouseover='doover(this)' onmouseout='doout(this)' onmousedown='"+this.obj+".light(this,"+this.node+");"+this.obj+".expand("+this.child+")' 
      title='"+txt+"'>"+txt+"</span></td></tr>
    <tr id='child"+this.child+"' style='display:"+(show?'':'none')+"'>
    <td class='node'>" 
      this.html+="<table cellspacing=0 cellpadding=0 border=0 
      style='margin-left:18;'>"
    this.child++
    this.node++;
    }dtree.prototype.addnode=function(txt,link)
    {
       this.msg[this.node]=[txt,link?link:'']
       this.html+="<tr><td class='node'><img src='"+this.icon[2]+"' align='absmiddle' onclick='"+this.obj+".light(this.nextsibling.nextsibling,"+this.node+")'><input type='checkbox' name='treenode' onclick='"+this.obj+".parentcheck(this)' style='display:"+(this.showcheck?'':'none')+"'><span onmouseover='doover(this)' onmouseout='doout(this)' onmousedown='"+this.obj+".light(this,"+this.node+")' title='"+txt+"'>"+txt+"</span></td></tr>"
    this.node++;
    }
    dtree.prototype.endfolder=function()
    {
     this.html+="</table></td></tr>"}
    dtree.prototype.expand=function(childnum,flag)
    {
      var isexpand=document.getelementbyid("child"+childnum).style.display
      document.getelementbyid("img"+chilenum).src=isexpand=='none'?this.icon[1]:this.icon[0]
      document.getelementbyid("child"+chilenum).style.display=isexpand=='none'?'':'none'}
    dtree.prototype.expandall=function(flag)
    {
      if(this.child>0)
      for(i=0;i<this.child;i++)
    {
      document.getelementbyid("img"+i).src=flag?this.icon[1]:this.icon[[0]
      document.getelementbyid("child"+i).style.display=flag?'':'none'}}
    dtree.prototype.checkall=function(obj,childnum)
    {
     obj.blur()
     var child=document.getelementbyid("child"+childnum)
     var nod=child.getelementsbytagname("input")
     for(i=0;i<node.length;i++)node[i].checked=obj.checked
     this.parentcheck(obj)
    }
    dtree.prototype.parentcheck=function(obj)
    {
     obj.blur()
     for(i=this.chile-1;i>=0;i--)
    {
      var checkparent=true
      var c=document.getelementbyid("child"+i)
      var node=c.getelementsbytagname("input")
      for(j=0;j<node.length;j++)if(!node[j].checked)checkparent=false
      document.getelementbyid("img"+i).nextsibling.checked=checkparent}}
    dtree.prototype.getcheckedvalue=function()

       var valve[]
       var nod=document.getelementbyid('deeptree').getelementsbytagname("input")
       for(i=0;i<node.length;i++)if(node[i].checked&node[i].name=="treenode")value[value.length]=this.msg[i][0]
      return value}
    dtree.prototype.init=function()
    {
      this.html+=(this.node>0?"":"<tr><td>暂时没有数据</td></tr>")+"</table>"
      document.write(this.html)}
    var tem=null
    function doover(o){
    o.classname='nodeover'}
    function doout(o)
    {
     o.classname=(tem==o?'nodefocus':'')}
    dtree.prototype.light=function(o,nodenum)
    {
     if(!tem)tem=o
    tem.classname=''
    o.classname='nodefocus'
    tem=o
    if(this.msg[nodenum][1])window.open(this.msg[nodenum][1],this.target);}