Jump to content

Taking User Input for building a Hierarchical Tree

- - - - -

  • Please log in to reply
No replies to this topic

#1
swathisambaraj

swathisambaraj

    Newbie

  • Members
  • Pip
  • 4 posts
Hi,

The below code gives a Treeview of Items and their sub-items,.. It shows in the hierarchical format,... but instead of hard-coding the input Item 1 , Sub-item 1 etc,..., i wanna give an input so that it will become a generic code and show the hierarchical tree view for any input we give,..
I tried giving some variables but it didn't work for me..
1)Could you please suggest me on this.. and also do u have any other ideas to build a hierarchical tree using HTML/JAVASCRIPT..
2)I also tried using DOM but it didn't work,.. I didn't know how to use DOM properly, suggest me if you have any idea about DOM



<ul>

* <li>

* * <a href="#" onclick="toggle('node1')">Item 1</a>

* * <ul id="node1" style="display:none">

* * * <li>Sub-item 1</li>

* * * <li>

* * * * <a href="#" onclick="toggle('node2')">Sub-item 2</a>

* * * * <ul id="node2" style="display:none">

* * * * * <li>Sub-sub-item 1</li>

* * * * * <li>Sub-sub-item 2</li>

* * * * </ul>

* * * </li>

* * * <li>Sub-item 3</li>

* * </ul>

* </li>

* <li>

* * <a href="#" onclick="toggle('node3')">Item 2</a>

* * <ul id="node3" style="display:none">

* * * <li>Sub-item 1</li>

* * * <li>Sub-item 2</li>

* * </ul>

* </li>

* <li>Item 3</li>

</ul>



Thanks in advance!




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users