link that depends on link

How can one display a hierarchy similar to an organization chart in which clicking on a link inside a textbox#1 will display its children link(s) inside textbox#2 and clicking on a link inside textbox#2 will display its children link(s) inside textbox#3, and so forth?  
...
user clicks on "MotherOfAllLinks", the textbox#1 will show

<%
for (Iterator firstLevels = firstLevelList.Iterator();firstLevels.hasNext;) {
FirstLevel firstLevel = (FirstLevel)firstLevels.next();
%>
<a href="<%=[what should I put in here?]"><%=firstLevel.getChildren()%>
<%}%>
....

I was thinking of something like "secondLevel.getChildren(selectedFirstLevelLink)" but "selectedFirstLevelLink" is created at runtime and I do not know how to store it. Pleaes help! Thank you in advance.



herkulisAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

TimYatesCommented:
I think you will need to build up multiple arrays so that javascript can just pick the one it wants...

OR!

Have 3 list boxes in a form

Put javascript into the onClick event on each, so that it posts the form

Then in the JSP, get the selected values from the lists, and fill in the possibilities for the next list along...
0
herkulisAuthor Commented:
Tim,
  Could you give some code examples? Thanks
0
TimYatesCommented:
Try this:

<html>
  <head>
    <title>test</title>
  </head>
  <body bgcolor="#ffffff">
    <script type="text/javascript">
      <!--
        function populate()
        {
          document.getElementById( "theform" ).submit() ;
        }
      -->
    </script>

<%
  java.util.ArrayList data1 = new java.util.ArrayList() ;
  // get the initial data
  data1.add( "a" );
  data1.add( "b" );
  data1.add( "c" );

  String val1 = request.getParameter( "list1" ) ;
  java.util.ArrayList data2 = new java.util.ArrayList() ;
  if( val1 != null )
  {
    // here we would get the values for list 2 based on the selected value for list 1
    // for testing, I'll just fill up some dummy values
    data2.add( val1 + ".1" ) ;
    data2.add( val1 + ".2" ) ;
    data2.add( val1 + ".3" ) ;
  }
  else
  {
    val1 = "" ;
  }

  String val2 = request.getParameter( "list2" ) ;
  java.util.ArrayList data3 = new java.util.ArrayList() ;
  if( val2 != null )
  {
    // here we would get the values for list 2 based on the selected value for list 1
    // for testing, I'll just fill up some dummy values
    data3.add( val1 + ".1" ) ;
    data3.add( val1 + ".2" ) ;
    data3.add( val1 + ".3" ) ;
  }
  else
  {
    val2 = "" ;
  }
%>

  <form id="theform">
    <select style="width:150px" name="list1" size="6" onchange="populate()">
<%
  for( int i = 0 ; i < data1.size() ; i++ ) {
%>
      <option value="<%= data1.get( i ).toString() %>" <%= val1.equals( data1.get( i ).toString() ) ? "SELECTED" : "" %>><%= data1.get( i ).toString() %></option>
<%
  }
%>
    </select>

    <select style="width:150px" name="list2" size="6" onchange="populate()">
<%
  for( int i = 0 ; i < data2.size() ; i++ ) {
%>
      <option value="<%= data2.get( i ).toString() %>" <%= val2.equals( data2.get( i ).toString() ) ? "SELECTED" : "" %>><%= data2.get( i ).toString() %></option>
<%
  }
%>
    </select>

    <select style="width:150px" name="list3" size="6">
<%
  for( int i = 0 ; i < data3.size() ; i++ ) {
%>
      <option value="<%= data3.get( i ).toString() %>"><%= data3.get( i ).toString() %></option>
<%
  }
%>
    </select>
  </form>
  </body>
</html>
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

TimYatesCommented:
It's not 100% right...but you should see what I'm getting at :-)
0
herkulisAuthor Commented:
Tim,

  That looked very good to me so far:) Can you make the list boxes scrollable in case there are alot of data? Also, can you make a 'master' hyperlink that would populate the first box? Thanks alot.
0
herkulisAuthor Commented:
Tim,

  I figured out the rest. Thank you very much. Happy Thanksgiving!
0
herkulisAuthor Commented:
Could the administrator give me back 60points which I mistakenly added? Thank you
0
TimYatesCommented:
You need to post here:  http://www.experts-exchange.com/Community_Support/ to get your 60 points back (just post a Q for 0 points asking) :-)

Good luck with it all :-)

Glad I could help :-)

Tim
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JSP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.