Hierarchical dropdownlist

Posted on 2003-03-20
Medium Priority
Last Modified: 2007-12-19
Hi all,

I need to display several informations coming from an Access DB but the display must appear according a hierarchical design.

For instance, I have a first dropdownlist and if I choose "Financial Area" , a second dropdownlist just comes below with the "Financial clients".  And if i choose a client from this list, a short description appears in a textarea or an iframe...

Financial Area ->
Financial Clients -> (not visible until Financial Area has been chosen)
Clients description (iframe or textarea)

I would like to make it in ASP or .NET

Your Xpert help is welcome !
Question by:tunGsten
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 14

Expert Comment

ID: 8173395
Here is an example :

<title>Dynamic JS Dropdowns</title>
<script language="JavaScript1.2">

var oList= new Object();
     oList["A"] = ["A1","A2", "A3","A4"];
     oList["B"] = ["B1","B2", "B3","B4"];
     oList["C"] = ["C1","C2", "C3","C4"];

function createSelect(obj,sID)
     var oTarget = document.forms['formName'].elements[sID];
     var sValue = obj.options[obj.options.selectedIndex].value;
     if (oList[sValue])
               addOptions(oTarget, oList[sValue]);

function addOptions(oSelect, arrList)
var iLen = oSelect.options.length;
     for (var i=0;i<iLen;i++)
               oSelect.options[0] = null;
var iLen = arrList.length;
     for (var i=0;i<iLen;i++)
               oSelect.options[oSelect.options.length]= new Option(arrList[i],arrList[i]);

<form id="formName">
<select name="selectBorder" onchange="createSelect(this,'selectColour')">
<option>-- select --</option>
<option value="A">A</option>
<option value="B">B</option>
<option value="B">C</option>

<select name="selectColour">

Author Comment

ID: 8174857
Yeah, it's a nice idea....but it's a javascript...

I don't want to type all my db content in a script....

but thanks anyway ;-)

Author Comment

ID: 8174981
Yeah, it's a nice idea....but it's a javascript...

I don't want to type all my db content in a script....

but thanks anyway ;-)
Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

LVL 17

Expert Comment

ID: 8175683


How browsers render it is up to the browser, some use an expanding menu form.

Accepted Solution

Ai3xSKC earned 150 total points
ID: 8175860

this is quite easy to do.  
I'll describe the basic ideas involved in achieving this in .NET cuz I don't have the IDE or the help file to get the exact attributes...

first, create 2 dropdownlist and 1 text area/label.
Make sure that these items all have "runat=server".  For each dropdown list, they have an event "OnSelectedIndexChanged"... set that to trigger a function in codebehind (this should be easy if you're using Visual Studio 7, since it'll set all the parameters for you too ... if not then just go to www.msdn.microsoft.com and look for reference)

<asp:dropdownlist id="levelList" runat="server" OnSelectedIndexChanged="OnSelectedIndexChanged_event"></asp:dropdownlist>

in codebehind
void OnSelectedIndexChanged_event(...)
  String sChoice=levelList.text;
  levelList.DataSource= ... DB return value
NOTE: be sure to register the event in C# or if you're using VB put "handles ..." following your function (sorry I don't remember the exact syntax...

In this codebehind function, you should retrieve TEXT or VALUE (of the chosen listitem.  With this information, you can hit the DB to retrieve information that will fill the next dropdownlist (I think you have to assign the return value to DataSource and then call DataBind).  
Similarly, in your codebehind for your SECOND dropdownlist, set the TEXT attribute of the asp:label or asp:textbox with the DB information you've retrieved.

sorry if I'm kinda vague on this cuz I haven't done this for a while now.  For better reference go to http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vjref98/html/com.ms.wfc.ui.ComboBoxStyle_DROPDOWN.asp and you'll have a better reference material there....

anyway hope you find your answer...
LVL 15

Expert Comment

ID: 8179045

Try to check the link below... might help...


Author Comment

ID: 8180751
Thanks for the help. It already gives me a good point to start

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Preface In the first article: A Better Website Login System (http://www.experts-exchange.com/A_2902.html) I introduced the EE Collaborative Login System and its intended purpose. In this article I will discuss some of the design consideratio…
I will show you how to create a ASP.NET Captcha control without using any HTTP HANDELRS or what so ever. you can easily plug it into your web pages. For Example a = 2 + 3 (where 2 and 3 are 2 random numbers) Session("Answer") = 5 then we…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
The viewer will learn how to count occurrences of each item in an array.
Suggested Courses

764 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