can any one help me out.what is the problem with this code?

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>


<script type="text/javascript">

function combofunction(){
 
// actions that you want to perform
 

//You will receive a different greeting based
//on what day it is. Note that Sunday=0,
//Monday=1, Tuesday=2, etc.

var value=document.getElementById("htmlcombo").value;

//var d=new Date();
//var theDay=d.getDay();
switch (value)
{
case 1:
document.getElementById("1").style.visibility = "visible";
  //document.write("Finally Friday");
  break;
case 2:
document.getElementById("2").style.visibility = "visible";
  //document.write("Super Saturday");
  break;
case 3:
document.getElementById("3").style.visibility = "visible";
  //document.write("Sleepy Sunday");
  break;
default:
  //document.write("I'm looking forward to this weekend!");
}

}
</script>
</head>

<body>
<select name="htmlcombo" id="htmlcombo">
    <option name="box1" value="1">Display Text1</option>
    <option name="box2" value="2">Display Text2</option>
    <option name="box3" value="3">Display Text3</option>
</select>
<input type="button" name="combovalue" value="Get Combo Value" onclick="combofunction()"> 

<div id="1" style="visibility:visible" >hello1</div>
<div id="2" style="visibility:hidden">hello2</div>
<div id="3" style="visibility:hidden">hello3</div>
<div id="4" style="visibility:hidden">hello4</div>

</body>
</html>

i want that when i select a number from combo box then i show the div which is hidden.i want div 3 to show when i select 3 from combo box.can any one help me out

try this:

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<script type="text/javascript">
function combofunction(x)
{
	var divEls = document.getElementsByTagName("div");
	var i = 0;
	
	for(i=0;i<divEls.length;i++)
	{
	divID=divEls[i].id;
	//alert(divID);
	//alert(x);
	if(divID == x)
		document.getElementById(divID).style.visibility = "visible";
	else
		document.getElementById(divID).style.visibility = "hidden";
	}
}
</script>
</head>
<body>
<select name="htmlcombo" id="htmlcombo" onChange="combofunction(this.value);">
 <option  value="0">Select</option>
    <option  value="1">Display Text1</option>
    <option  value="2">Display Text2</option>
    <option  value="3">Display Text3</option>
</select>

<div id="1" style="visibility:hidden" >hello1</div>
<div id="2" style="visibility:hidden">hello2</div>
<div id="3" style="visibility:hidden">hello3</div>
<div id="4" style="visibility:hidden">hello4</div>
</body>
</html>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.