Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 229
  • Last Modified:

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.



0
herkulis
Asked:
herkulis
  • 4
  • 4
1 Solution
 
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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

Featured Post

Independent Software Vendors: 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!

  • 4
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now