0% found this document useful (0 votes)
7 views2 pages

Exp11 3

Uploaded by

vedanti.p12
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views2 pages

Exp11 3

Uploaded by

vedanti.p12
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

3.Dynamically changing the menu.

<html>
<head>
<script>
array = new Array("Ram", "Pavan", "Mira");
array1 = new Array("Ajay", "Mary", "Riya");
function disp(obj)
{
for (i = document.f1.department.options.length - 1; i >= 0; i--)
{
document.f1.department.options.remove(i);
}
dept = obj.options[obj.selectedIndex].value;
if (dept == "1")
{
for (i = 0; i < array.length; i++)
{
document.f1.department.options[i] = new Option(array[i]);
}
}
if (dept == "2")
{
for (i = 0; i < array1.length; i++)
{
document.f1.department.options[i] = new Option(array1[i]);
}
}
}
</script>
</head>
<body>
<form name="f1">
<select name="dept" onchange="disp(this)">
<option value="o">Departments</option>
<option value="1">Computer</option>
<option value="2">Information Technology</option>
</select>
<select name="department">
<option value="o">Employees</option>
</select>
</form>
</body>
</html>

Output:

You might also like