Values of drop-down list depends on another

I have a web page with two drop down lists.

One list shows the following options:
Monday
Tuesday
Wednesday

When the user selects "Monday", the second drop down list should have only the following options:
7.00pm
8.00pm
9.00pm

When the user selects "Tuesday", the second drop down list should have only the following options:
8.00pm
9.00pm
10.00pm

You get the idea. How do I implement something like that in javascript? Thanks!
LVL 9
yongsingAsked:
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.

sajuksCommented:
//try something like this
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>  </title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">

<script language="javascript" type="text/javascript">
<!--
weekdys = new Array(4)
weekdys [0] = new Array(1)
weekdys [1]= new Array(1)
weekdys [2] = new Array(1)
weekdys [3] = new Array(1)

//Empty (0)
weekdys [0][0] = " "

//Monday
weekdys [1][0] = "7.00pm"
weekdys [1][1] = "8.00pm"
weekdys [1][2] = "9.00pm"
//tuesday
weekdys [2][0] = "8.00pm"
weekdys [2][1] = "9.00pm"
weekdys [2][2] = "10.00pm"

//wednesday
weekdys [3][0] = "11.00pm"
weekdys [3][1] = "12.00pm"

//credit to ftb
function populatedw()
{
var num=document.forms[0].dayoftheweek.selectedIndex
var boxlength = 0

document.forms[0].weekdys.selectedIndex = 0
for ( ctr=0;ctr<weekdys[num].length;ctr++)
 {
 boxlength++;
 document.forms[0].weekdys.options[ctr] = new Option(weekdys[num] [ctr], weekdys[num][ctr]);
 }

document.forms[0].weekdys.length = boxlength;
document.forms[0].weekdys.options.length = boxlength;
document.forms[0].weekdys.focus() ;

}


//-->
</script>
</head>

<body>
<form action="" method=post >
<select id=select1 name=dayoftheweek onchange="populatedw()">
<option value=""></option>
<option value=monday >monday</option>
<option value=tuesday>tuesday</option>
<option value=wednesday>wednesday</option>

</select>

<p>
<select id=select2 name=weekdys>
<option></option>
</select>

</form>
</body>
</html>

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
yongsingAuthor Commented:
Hi, just to let you know that I'll be looking at your solution. :)
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.