http://blog.csdn.net/CutBug/archive/2007/10/26/1845106.aspx

解决方案 »

  1.   

    function creatElement2(tmpTreeCode,youAdd){
                //alert('创建row2');
                    // alert(tmpTreeCode);
    var table=document.all("showTable");
    var tb = table.childNodes[0];
    var arr=tmpTreeCode.split("/");
    var inner;
    var postTr;
    var postTd;
    var i;
    var id;
    var id1;
    //alert(arr.length);
    for(i=0;i<arr.length;i++){
     if(i%5==0){
                             id1=arr[i];
     postTr=createTr(arr[i],"");  
     }
     if(i%5==1){
                               
     }
     if(i%5==3){
                             var tag=arr[i];
     if(tag=="1"){
     inner='<img  id=\"img-'+id1+'\" align=\"absmiddle\" src=\"./photospecial/images/ftv2plastnode.gif\" width=16 height=22 border=0><font id=\"font-'+id1+'\" class=\"font\">';
     }else{
     inner='<img  id=\"img-'+id1+'\" align=\"absmiddle\" src=\"./photospecial/images/lastopennode.gif\" width=16 height=22 border=0><font id=\"font-'+id1+'\" class=\"font\">';
     }
      postTr.tag=arr[i];
     }
     
     if(i%5==4){
     id=id1
     inner+=(arr[i]+'</font>');
     postTd=createTd("",inner);
     postTd1=createTd("",id1);
     var img="<IMG  border=0 src=\"./photospecial/images/NoPicture.jpg\" border=\"0\" width=\"50\">";
     postTd2=createTd("",img);
                             var chec="<td width=\"3%\"><input type=\"checkbox\" name=\"chec_\"  value="+id+"></td>"
     postTd0=createTd("",chec);
     postTr.appendChild(postTd0);
     postTr.appendChild(postTd1); 
     postTr.appendChild(postTd); 
      postTr.appendChild(postTd2); 
     postTr.name=arr[i];
    // tb.insertBefore(postTr,parentObj.nextSibling);
      tb.appendChild(postTr);
     postTd.onclick = function addnew(){doFolder(this);}
     postTd1.onclick = function addnew(){doFolder(this);}
     postTd2.onclick = function addnew(){doFolder(this);}
     postTr.oncontextmenu=function addnew1()
     {
      doCtxMenu(this);
         }
     }
    }
    }function createImg(id,text){
       var newIMG = document.createElement("IMG");  //创建html 元素
       newIMG.src=text;
       newIMG.width=50;
       newIMG.border=0;
       
       return newIMG;
    }function createTr(id,text){
       var newTr = document.createElement("tr");  //创建html 元素
       newTr.onclick="doFolder(this)";
       newTr.innerHTML = text;
       newTr.id=id;
       newTr.bgColor='#cbdaf7';
       newTr.name=""
       //newTr.tag=1;
       newTr.tag2=0;
       newTr.parentID="parent-"+parentObj.id;
       return newTr;
    }function createTd(className,text){
       var newTd = document.createElement("td");
       newTd.innerHTML = text;
       return newTd;
    }