Results 1 to 4 of 4

Thread: How do you autopopulate the smart folding tree menu

  1. #1
    Join Date
    Jan 2006
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default How do you autopopulate the smart folding tree menu

    DD = Smart Folding Tree menu
    http://www.dynamicdrive.com/dynamicindex1/navigate1.htm

    Hello everyone and thanks for taking the time to read this posting. I happened across this "smart folding tree menu" script whilst browsing the net for such a script, it is great and so simple to use, especially for someone who has limited skills when it comes to coding, I have got the script customized to do what i want it to except for one issue. Some of the levels in the tree menu i want to autopopulate (create on the fly) from data contained in a seperate file (the data in this file changes from time to time, this is why I dont want to hard code all of the tree menu). So for instance, i open up a level on the tree and when i click on the next level down it will read the external file and auto build the rest of the tree sub levels. I am ok with perl and cgi so i don't mind using that code to get at the data and build the tree.

    My problem is with the existing code, i don't know how to break out of that to get the external data.

    thanks, Mark.

  2. #2
    Join Date
    Apr 2006
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Mark did u ever figure out how to do this? Does anyone know how to build the tree on the fly don't really need to read from a file but would like to build the tree on the fly.

    Any help greatly appreciated

  3. #3
    Join Date
    Nov 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I think you may be asking the wrong question.
    Perhaps you should be asking:

    "How do I auto-generate the simple unordered list, and then create the tree?"

    Is that really what you want to know?

  4. #4
    Join Date
    Nov 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Using Perl/CGI the task should be simple, because you'll have more flexibility. The key in the JavaScript is just to use document.writeln() to get the list into the script.

    I tried a simple test by replacing the example menu list with the JavaScript code to create that script. It worked just fine that way. Here's the appropriate excerpt from that code:

    <ul id="treemenu1" class="treeview">

    <script language="Javascript">

    document.writeln("<li>Item 1</li>");
    document.writeln("<li>Item 2</li>");

    document.writeln("<li>Folder 1");
    document.writeln(" <ul>");
    document.writeln(" <li>Sub Item 1.1</li>");
    document.writeln(" <li>Sub Item 1.2</li>");
    document.writeln(" </ul>");
    document.writeln("</li>");
    document.writeln("<li>Item 3</li>");

    document.writeln("<li>Folder 2");
    document.writeln(" <ul>");
    document.writeln(" <li>Sub Item 2.1</li>");
    document.writeln(" <li>Folder 2.1");
    document.writeln(" <ul>");
    document.writeln(" <li>Sub Item 2.1.1</li>");
    document.writeln(" <li>Sub Item 2.1.2</li>");
    document.writeln(" </ul>");
    document.writeln(" </li>");
    document.writeln("</ul>");
    document.writeln("</li>");

    document.writeln("<li>Item 4</li>");
    document.writeln("</ul>");
    </script>

    Expanding on this, you could possibly use a JavaScript include that would contain the writeln statements to create the list. That include file could be auto-generated by a Perl script if you like.

    You might also be able to use the eval() function in JavaScript to dynamically create the list, althought I haven't tried this.

    Does this help?

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •