Link to home
Start Free TrialLog in
Avatar of coreybryant
coreybryantFlag for United States of America

asked on

3 level combo box Dynamically

Ref: https://www.experts-exchange.com/questions/21195901/3-level-combo-box-Dynamically.html

Seems to work fine with only numbers.  Now I need one with the letters :( - anyone know what I need to change on this one

I need to make 3 level of Combo box

1st one there are three elements 1, 2, 3

If we select 1 then second combobox will enable and it should shows select choice 1.1, 1.2,1.3

If we select 2 then second combobox will enable and it should shows select choice 2.1, 2.2,2.3

If we select 3 then second combobox will enable and it should shows select choice 3.1, 3.2,3.3

If we select 1.1 then third combobox will enable and its should shows select choice 1.1.1, 1.1.2,1.1.3

If we select 1.2 then third combobox will enable and its should shows select choice 1.2.1, 1.2.2,1.2.3

If we select 1.3 then third combobox will enable and its should shows select choice 1.3.1, 1.3.2,1.3.3

Thanks!

-Corey
Avatar of archrajan
archrajan

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
<script>
function myfunc()
{
var a = document.myform
var b = a.mysel1.selectedIndex
if(a.mysel1.options[b].value == "1")
{
var opt = new Option("1.1","1.1","1.1")
var opt1 = new Option("1.2","1.2","1.2")
var opt2 = new Option("1.3","1.3","1.3")

a.mysel2.options[0] = opt;
a.mysel2.options[1] = opt1;
a.mysel2.options[2] = opt2;
}
if(a.mysel1.options[b].value == "2")
{
var opt = new Option("2.1","2.1","2.1")
var opt1 = new Option("2.2","2.2","2.2")
var opt2 = new Option("2.3","2.3","2.3")

a.mysel2.options[0] = opt;
a.mysel2.options[1] = opt1;
a.mysel2.options[2] = opt2;
}
if(a.mysel1.options[b].value == "3")
{
var opt = new Option("3.1","3.1","3.1")
var opt1 = new Option("3.2","3.2","3.2")
var opt2 = new Option("3.3","3.3","3.3")

a.mysel2.options[0] = opt;
a.mysel2.options[1] = opt1;
a.mysel2.options[2] = opt2;
}

}
</script>
</HEAD>

<BODY>
<form name = "myform">
<select name = "mysel1" onchange = "myfunc();">
<option value = ".">select here </option>
<option value = "1">1</option>
<option value = "2">2</option>
<option value = "3">3</option>
</select>
<select name = "mysel2"></select>
<select name = "mysel3"></select>
</form>

</BODY>
</HTML>

Avatar of coreybryant

ASKER

Thanks - that looks close but I added
<select name = "mysel2">test1</select>
<select name = "mysel3">test2</select>
because the last drop down seems to be empty?

-Corey
ASKER CERTIFIED SOLUTION
Avatar of archrajan
archrajan

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
Gotcha - sorry about that.  I think this should work

-Corey
Thanks a lot for the points