Link to home
Start Free TrialLog in
Avatar of tunGsten
tunGsten

asked on

Hierarchical dropdownlist

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 !
Avatar of avner
avner

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>
Avatar of tunGsten

ASKER

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 ;-)
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 ;-)
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.
ASKER CERTIFIED SOLUTION
Avatar of Ai3xSKC
Ai3xSKC

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks for the help. It already gives me a good point to start