?
Solved

Expanding nested lists with JavaScript

Posted on 2012-09-13
3
Medium Priority
?
444 Views
Last Modified: 2012-09-13
I am working on a web page where is need to hide and reveal text in stages. Conceptually, the page would look something like this.

MainTopic 1
Subtopic 1.1
Subtopic 1.2
Subtopic 1.3
Subtopic 1.4

Full Description 1.4
MainTopic 2
MainTopic 3
MainTopic 4


Initially, all the user would see is the list of 4 main topics. Click on a main topic and a list of subtopics appears directly beneath the main topic. Click on any subtopic and a full description, usually 5 to 10 lines of text, appears beneath the subtopic.

Using innerHTML in Javascript, I have no problem creating the first level of expansion – getting to the subtopics. The problems start with trying to get the full descriptions to pop up. It appears to require nested functions, and I cannot get them to work together.

Is there a solution to this issue? A little code example would be a great help.
0
Comment
Question by:gpinzino
  • 2
3 Comments
 
LVL 60

Expert Comment

by:Julian Hansen
ID: 38395530
This is an example of what you might be looking for. Might need tweaking depnding on whether you want only one panel to show at a time - i.e. if open panels must close when new panel / subitem selected
t127.html
0
 
LVL 1

Author Comment

by:gpinzino
ID: 38395687
Thanks for the quick response. This certainly looks good. Yes, I would need it to open only one panel at a time. How would I modify the code to do that?
0
 
LVL 60

Accepted Solution

by:
Julian Hansen earned 2000 total points
ID: 38395866
A few small changes
t127.html
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question