在php页面上显示树视图中的数据

时间:2011-11-03 12:23:23

标签: php javascript html ajax

我有一个网站(Php和Javascript),在左侧我想显示类别和相应的子类别。

树应该可以移动,就像在这个链接http://www.xtlinks.com/articles/

上一样

请建议我该怎么做。

2 个答案:

答案 0 :(得分:0)

查看A List Apart - 那里有很多很好的例子。

对于崩溃影响,请查看jQuery的.slide()方法

答案 1 :(得分:0)

这两个链接很好地解释了事情。

http://www.howtocreate.co.uk/tutorials/jsexamples/listCollapseExample.html

http://code.stephenmorley.org/javascript/collapsible-lists/

或者只是尝试一下。

<html>
<head>
    <script type="text/javascript">
    function changeDisplayState(sBoxId)
    {
    if (document.getElementById) {
    oBox = document.getElementById(sBoxId).style;
    if (oBox.display == "none" || oBox.display == "NULL") {
    oBox.display = "block";
    } else {
    oBox.display = "none";
    }
    }
    }
</script>
</head>


<body>
        <ul>
<li>parent 1</li>
<li><a href="javascript:changeDisplayState('childset_1')">parent 2</a>
<ul id="childset_1">
<li><a href="javascript:changeDisplayState('grandchildset_1')">child 1</a>
<ul id="grandchildset_1">
<li>grandchild 1</li>
</ul>
</li>
</ul>
</li>
</ul>
</body>
</html>