In javascript chained select menus are available.first
select menu is worked and others are disabled.when we
select any one option then the next select menu will worked
having option releated to selcted in first select menu.How
it possible? what is the coading of this programme?



In javascript chained select menus are available.first select menu is worked and others are disabl..

Answer / mangala bhat

It possible by using onChange event.

Code:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01
Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script type="text/javascript">
function change()
{

var cat = document.getElementById("category");
if(cat.value =="Javascript")
{


document.getElementById("javaScript").removeAttribute("disabled");

document.getElementById("java").setAttribute("disabled","true");
}
else
{

document.getElementById("javaScript").setAttribute("disabled","true");
document.getElementById("java").removeAttribute("disabled");

}
}
</script>
<meta http-equiv="Content-Type" content="text/html;
charset=UTF-8">
<title>Html menu</title>
</head>
<body>
Category :<select id="category" name = "category"
onChange=change();>
<option value="Select">Select ...</option>
<option value="Javascript">Javascript</option>
<option value="Java">Java</option>
</select>
&nbsp;
JavaScript:<select id="javaScript" name = "javaScript"
disabled="disabled" >
<option value="JS Objects"> JS Objects</option>
<option value = "JS Advanced">JS Advanced</option>
</select>
&nbsp;
Java:<select id="java" name = "java" disabled="disabled" >
<option value="Java Swings"> Java Swings</option>
<option value = "Java Collections">Java Collections</option>
</select>
</body>
</html>

Is This Answer Correct ?    6 Yes 1 No

Post New Answer

More JavaScript Interview Questions

How to remove the event listener?

0 Answers  


hi i want validations for two dropdown lists in java script.when user enter to second dropdown list by skipping first dropdown list we should get alert box. please help me very urgent

2 Answers  


What kind of conditional statements does JavaScript support?

0 Answers  


What is the difference between attributes and property?

0 Answers  


What are javascript closures?

0 Answers  


Name some of the ways in which Type Conversion is possible?

0 Answers  


Explain why "self" is needed instead of "this".

0 Answers  


Is javascript default scripting language?

0 Answers  


What is a closure javascript?

0 Answers  


What close() does in javascript?

0 Answers  


Why is java better than javascript?

0 Answers  


Write a Program of Simple Calculator in JavaScript using HTML.

1 Answers  


Categories