2011-11-03 84 views
0

我有一個網站(PHP和Javascript),在左側我想顯示類別和相應的SubCategories。在樹上顯示數據在php頁面上查看

樹應該是可移動的像作爲這個鏈接http://www.xtlinks.com/articles/

請建議我應該怎麼做。

+0

本網站上沒有樹。你是在談論他們的主頁http://www.xtlinks.com?然後你可以使用多個UL – NCode

+0

@NCode我想創建一個理想的可移動控件就像頂級類別涵蓋鏈接提供的類別列表 – Mohit

+0

@nickb我沒有從我應該從哪裏開始 – Mohit

回答

0

的.slide()方法,這兩個環節上解釋了事情真的很好。

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>