3 level combo box Dynamically

Ref: http://www.experts-exchange.com/Web/Web_Languages/JavaScript/Q_21195901.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
LVL 29
coreybryantAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

archrajanCommented:
<!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>

0
coreybryantAuthor Commented:
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
0
archrajanCommented:
U have to add similar way for 2.1, 2.2, 2.3 and same for 3.1,3.2,3.3

<!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[1] = opt;
a.mysel2.options[2] = opt1;
a.mysel2.options[3] = 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[1] = opt;
a.mysel2.options[2] = opt1;
a.mysel2.options[3] = 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[1] = opt;
a.mysel2.options[2] = opt1;
a.mysel2.options[3] = opt2;
}
if(a.mysel1.options[b].value == ".")
{
a.mysel2.length = null;
}

}
function myfunc2()
{
var a = document.myform
var b = a.mysel2.selectedIndex
if(a.mysel2.options[b].value == "1.1")
{
var opt = new Option("1.1.1","1.1.1","1.1.1")
var opt1 = new Option("1.1.2","1.1.2","1.1.2")
var opt2 = new Option("1.1.3","1.1.3","1.1.3")

a.mysel3.options[1] = opt;
a.mysel3.options[2] = opt1;
a.mysel3.options[3] = opt2;
}
if(a.mysel2.options[b].value == "1.2")
{
var opt = new Option("1.2.1","1.2.1","1.2.1")
var opt1 = new Option("1.2.2","1.2.2","1.2.2")
var opt2 = new Option("1.2.3","1.2.3","1.2.3")

a.mysel3.options[1] = opt;
a.mysel3.options[2] = opt1;
a.mysel3.options[3] = opt2;
}
if(a.mysel2.options[b].value == "1.3")
{
var opt = new Option("1.3.1","1.3.1","1.3.1")
var opt1 = new Option("1.3.2","1.3.2","1.3.2")
var opt2 = new Option("1.3.3","1.3.3","1.3.3")

a.mysel3.options[1] = opt;
a.mysel3.options[2] = opt1;
a.mysel3.options[3] = opt2;
if(a.mysel1.options[b].value == ".")
{
a.mysel2.length = null;
}
}
}

</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" onchange = "myfunc2();">
<option value = ".">Select here </option>
</select>
<select name = "mysel3">
<option value = ".">Select here </option>
</select>
</form>

</BODY>
</HTML>
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
coreybryantAuthor Commented:
Gotcha - sorry about that.  I think this should work

-Corey
0
archrajanCommented:
Thanks a lot for the points
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.