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

x
?
Solved

Hierarchical dropdownlist

Posted on 2003-03-20
7
Medium Priority
?
418 Views
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 !
0
Comment
Question by:tunGsten
7 Comments
 
LVL 14

Expert Comment

by:avner
ID: 8173395
Here is an example :


<html>
<head>
<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]);
          }

}
</script>
</head>
<body>
<form id="formName">
OPTIONS
<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>

<select name="selectColour">
</select>
</form>
</body>
</html>
0
 

Author Comment

by:tunGsten
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 ;-)
0
 

Author Comment

by:tunGsten
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 ;-)
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.

 
LVL 17

Expert Comment

by:dorward
ID: 8175683
Optgroup.

http://www.w3.org/TR/html4/interact/forms.html#h-17.6

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

Accepted Solution

by:
Ai3xSKC earned 150 total points
ID: 8175860
hey...

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)

eg:
<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
  levelList.DataBind();
}
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...
0
 
LVL 15

Expert Comment

by:gladxml
ID: 8179045
tunGsten,

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

http://www.experts-exchange.com/Web/Web_Languages/ASP/Q_20458348.html
0
 

Author Comment

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

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
This article covers the basics of the Sass, which is a CSS extension language. You will learn about variables, mixins, and nesting.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

571 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