在ASP中如何实现树型结构,?

时间:2022-05-16 12:28:06
在ASP中如何实现树型结构,?注意要求把数据库中的数据显示成树型结构,

5 个解决方案

#1


下面是一个树型结构,但不是数据库的,你改一下:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<link rel="stylesheet" href="css.css">
<title></title>
</head>
<base target="main">

<script language="JavaScript1.2">
scores = new Array(20);
var numTotal=0;
NS4 = (document.layers) ? 1 : 0;
IE4 = (document.all) ? 1 : 0;
ver4 = (NS4 || IE4) ? 1 : 0;

if (ver4) {    with (document) {        write("<STYLE TYPE='text/css'>");        if (NS4) {            write(".parent {position:absolute; visibility:visible}");            write(".child {position:absolute; visibility:visible}");            write(".regular {position:absolute; visibility:visible}")        }        else {            write(".child {display:none}")        }        write("</STYLE>");    }}



function getIndex(el) {    ind = null;    for (i=0; i<document.layers.length; i++) {        whichEl = document.layers[i];        if (whichEl.id == el) {            ind = i;            break;        }    }    return ind;}


function arrange() {    nextY = document.layers[firstInd].pageY +document.layers[firstInd].document.height;    for (i=firstInd+1; i<document.layers.length; i++) {        whichEl = document.layers[i];        if (whichEl.visibility != "hide") {            whichEl.pageY = nextY;            nextY += whichEl.document.height;        }    }}function initIt(){    if (!ver4) return;    if (NS4) {        for (i=0; i<document.layers.length; i++) {            whichEl = document.layers[i];            if (whichEl.id.indexOf("Child") != -1) whichEl.visibility = "hide";       }        arrange();    }    else {        divColl = document.all.tags("DIV");        for (i=0; i<divColl.length; i++) {            whichEl = divColl(i);            if (whichEl.className == "child") whichEl.style.display = "none";        }    }}

#2


http://xml.sz.luohuedu.net/

#3



function expandIt(el) { if (!ver4) return;    if (IE4) {        whichEl1 = eval(el + "Child"); for(i=1;i<=numTotal;i++){ whichEl = eval(scores[i] + "Child"); if(whichEl!=whichEl1) { whichEl.style.display = "none"; } }        whichEl1 = eval(el + "Child");        if (whichEl1.style.display == "none") {            whichEl1.style.display = "block";        }        else {            whichEl1.style.display = "none";        }    }    else {        whichEl = eval("document." + el + "Child"); for(i=1;i<=numTotal;i++){ whichEl = eval("document." + scores[i] + "Child"); if(whichEl!=whichEl1) { whichEl.visibility = "hide"; } }        if (whichEl.visibility == "hide") {            whichEl.visibility = "show";        }        else {            whichEl.visibility = "hide";        }        arrange();    }}



onload = initIt;

</script>




<body bgcolor="#eeeeee" topmargin="0" leftmargin="5">
<table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td height=5></td>
</tr>
</table>
<b>通用</b>
<br>

<div id='KB1Parent' class='parent'> <a href="#" onClick="expandIt('KB1'); return false"> 
  <IMG SRC='../images/workplan.gif' BORDER=0 width="30" height="16">网站信息管理</a> 
</div>
<div id='KB1Child' class='child'> <a href="add_class_1.asp"> <IMG SRC='../images/blank.gif' BORDER=0>添加大类</a><br>
  <a href="add_class_2.asp"> <IMG SRC='../images/blankend.gif' BORDER=0>添加小类</a><br>
  <a href="add_product.asp"> <IMG SRC='../images/blankend.gif' BORDER=0>添加产品</a><br>
  <a href="product_check.asp"> <IMG SRC='../images/blankend.gif' BORDER=0>产品审查</a><br>
</div>

#4


............
<div id='KB6Parent' class='parent'> <a href="#" onClick="expandIt('KB6'); return false"> 
  <IMG SRC='../images/yuyue.gif' BORDER=0 width="30" height="16">退出管理</a></div>
<div id='KB6Child' class='child'> <a href="../index.asp" target="_parent"> <IMG SRC='../images/blankend1.gif' BORDER=0>退出本系统</a><br>
</div>

<SCRIPT>
numTotal=6;scores[1]='KB6';scores[2]='KB1';scores[3]='KB2';scores[4]='KB3';scores[5]='KB4';scores[6]='KB5';</SCRIPT>

</body>
</html>

#5


<style>
<!--

#foldheader{list-style-image:url('images/ico/find.jpg')}
#foldheader1{list-style-image:url('images/ico/feiyong.jpg')}
#user{list-style-image:url('images/ico/user.jpg')}

//-->
</style>
<script language="JavaScript1.2">
<!--
//以下可以改为你的图标
var head="display:''"
img1=new Image()
img1.src="fold.jpg"
img2=new Image()
img2.src="open.jpg"

function change(){
   if(!document.all)
      return
   if (event.srcElement.id=="foldheader") {
      var srcIndex = event.srcElement.sourceIndex
      var nested = document.all[srcIndex+1]
      if (nested.style.display=="none") {
         nested.style.display=''
         event.srcElement.style.listStyleImage="url('images/ico/find.jpg')"
      }
      else {
         nested.style.display="none"
         event.srcElement.style.listStyleImage="url('images/ico/find.jpg')"
      }
   }
}

document.onclick=change

//-->
</script>
 <ul>
    <li id="foldheader">◆</li>
    <ul  id="user" style="display:none">
      <li > <font color="#FFFFFF"><a href="cx/qbfycx.asp" target="mainFrame">1</a></font></li>
      <li ><font color="#FFFFFF"><a href="cx/dhcx.asp" target="mainFrame">2</a></font></li>

      <li  > <font color="#FFFFFF"><a href="cx/zhhcx.asp" target="mainFrame">3</a></font> 
      </li>
    </ul>
  </ul>


(转载)

http://expert.csdn.net/Expert/topic/1452/1452592.xml?temp=.3141748

#1


下面是一个树型结构,但不是数据库的,你改一下:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<link rel="stylesheet" href="css.css">
<title></title>
</head>
<base target="main">

<script language="JavaScript1.2">
scores = new Array(20);
var numTotal=0;
NS4 = (document.layers) ? 1 : 0;
IE4 = (document.all) ? 1 : 0;
ver4 = (NS4 || IE4) ? 1 : 0;

if (ver4) {    with (document) {        write("<STYLE TYPE='text/css'>");        if (NS4) {            write(".parent {position:absolute; visibility:visible}");            write(".child {position:absolute; visibility:visible}");            write(".regular {position:absolute; visibility:visible}")        }        else {            write(".child {display:none}")        }        write("</STYLE>");    }}



function getIndex(el) {    ind = null;    for (i=0; i<document.layers.length; i++) {        whichEl = document.layers[i];        if (whichEl.id == el) {            ind = i;            break;        }    }    return ind;}


function arrange() {    nextY = document.layers[firstInd].pageY +document.layers[firstInd].document.height;    for (i=firstInd+1; i<document.layers.length; i++) {        whichEl = document.layers[i];        if (whichEl.visibility != "hide") {            whichEl.pageY = nextY;            nextY += whichEl.document.height;        }    }}function initIt(){    if (!ver4) return;    if (NS4) {        for (i=0; i<document.layers.length; i++) {            whichEl = document.layers[i];            if (whichEl.id.indexOf("Child") != -1) whichEl.visibility = "hide";       }        arrange();    }    else {        divColl = document.all.tags("DIV");        for (i=0; i<divColl.length; i++) {            whichEl = divColl(i);            if (whichEl.className == "child") whichEl.style.display = "none";        }    }}

#2


http://xml.sz.luohuedu.net/

#3



function expandIt(el) { if (!ver4) return;    if (IE4) {        whichEl1 = eval(el + "Child"); for(i=1;i<=numTotal;i++){ whichEl = eval(scores[i] + "Child"); if(whichEl!=whichEl1) { whichEl.style.display = "none"; } }        whichEl1 = eval(el + "Child");        if (whichEl1.style.display == "none") {            whichEl1.style.display = "block";        }        else {            whichEl1.style.display = "none";        }    }    else {        whichEl = eval("document." + el + "Child"); for(i=1;i<=numTotal;i++){ whichEl = eval("document." + scores[i] + "Child"); if(whichEl!=whichEl1) { whichEl.visibility = "hide"; } }        if (whichEl.visibility == "hide") {            whichEl.visibility = "show";        }        else {            whichEl.visibility = "hide";        }        arrange();    }}



onload = initIt;

</script>




<body bgcolor="#eeeeee" topmargin="0" leftmargin="5">
<table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td height=5></td>
</tr>
</table>
<b>通用</b>
<br>

<div id='KB1Parent' class='parent'> <a href="#" onClick="expandIt('KB1'); return false"> 
  <IMG SRC='../images/workplan.gif' BORDER=0 width="30" height="16">网站信息管理</a> 
</div>
<div id='KB1Child' class='child'> <a href="add_class_1.asp"> <IMG SRC='../images/blank.gif' BORDER=0>添加大类</a><br>
  <a href="add_class_2.asp"> <IMG SRC='../images/blankend.gif' BORDER=0>添加小类</a><br>
  <a href="add_product.asp"> <IMG SRC='../images/blankend.gif' BORDER=0>添加产品</a><br>
  <a href="product_check.asp"> <IMG SRC='../images/blankend.gif' BORDER=0>产品审查</a><br>
</div>

#4


............
<div id='KB6Parent' class='parent'> <a href="#" onClick="expandIt('KB6'); return false"> 
  <IMG SRC='../images/yuyue.gif' BORDER=0 width="30" height="16">退出管理</a></div>
<div id='KB6Child' class='child'> <a href="../index.asp" target="_parent"> <IMG SRC='../images/blankend1.gif' BORDER=0>退出本系统</a><br>
</div>

<SCRIPT>
numTotal=6;scores[1]='KB6';scores[2]='KB1';scores[3]='KB2';scores[4]='KB3';scores[5]='KB4';scores[6]='KB5';</SCRIPT>

</body>
</html>

#5


<style>
<!--

#foldheader{list-style-image:url('images/ico/find.jpg')}
#foldheader1{list-style-image:url('images/ico/feiyong.jpg')}
#user{list-style-image:url('images/ico/user.jpg')}

//-->
</style>
<script language="JavaScript1.2">
<!--
//以下可以改为你的图标
var head="display:''"
img1=new Image()
img1.src="fold.jpg"
img2=new Image()
img2.src="open.jpg"

function change(){
   if(!document.all)
      return
   if (event.srcElement.id=="foldheader") {
      var srcIndex = event.srcElement.sourceIndex
      var nested = document.all[srcIndex+1]
      if (nested.style.display=="none") {
         nested.style.display=''
         event.srcElement.style.listStyleImage="url('images/ico/find.jpg')"
      }
      else {
         nested.style.display="none"
         event.srcElement.style.listStyleImage="url('images/ico/find.jpg')"
      }
   }
}

document.onclick=change

//-->
</script>
 <ul>
    <li id="foldheader">◆</li>
    <ul  id="user" style="display:none">
      <li > <font color="#FFFFFF"><a href="cx/qbfycx.asp" target="mainFrame">1</a></font></li>
      <li ><font color="#FFFFFF"><a href="cx/dhcx.asp" target="mainFrame">2</a></font></li>

      <li  > <font color="#FFFFFF"><a href="cx/zhhcx.asp" target="mainFrame">3</a></font> 
      </li>
    </ul>
  </ul>


(转载)

http://expert.csdn.net/Expert/topic/1452/1452592.xml?temp=.3141748