On a web page, the contents of a div must dynamically change when a particular selection is made from a drop down list. Below is my code, I don't know where I am going wrong? Any help would be appreciated.
<head>
<script type="text/javascript">
function fn()
{
var x = document.getElementsById("select").selectedIndex;
var y = document.getElementById("a").innerHTML;
if (X == "0")
{
y = " So.. ur a conman" ;
}
else
{
y = "oops";
}
}
window.onload = fn() ;
x.onchange = fn() ;
</script>
<body>
<select name="select" id="select">
<option value="consulting"> Consulting </option>
<option value="industry"> Industry </option>
</select>
<div id="a" style="background-color:blue; width:1200px; height:20px; color:black;">
</div>
</body>
</html>