Print
27
July
2010

Div Toggle Using Select-List Example

This example has 3 div sections, which are controlled by the option that is selected from the select-list field.

Copy and paste the following code into a HTML file to test it.




<html>
<head>
<title>Div Toggle Example</title>
<script type="text/javascript">
var lastDiv = "";
function showDiv(divName) {
// hide last div
if (lastDiv) {
document.getElementById(lastDiv).className = "hiddenDiv";
}
//if value of the box is not nothing and an object with that name exists, then change the class
if (divName && document.getElementById(divName)) {
document.getElementById(divName).className = "visibleDiv";
lastDiv = divName;
}
}
</script>
<style type="text/css" media="screen">
.hiddenDiv {
display: none;
}
.visibleDiv {
display: block;
border: 1px grey solid;
}
</style>
</head>
<body>
<form id="FormName" action="blah.php" method="get"
name="FormName">
<select name="selectName" size="1"
onchange="showDiv(this.value);">
<option value="">Choose One...</option>
<option value="one">first</option>
<option value="two">second</option>
<option value="three">third</option>
</select>
</form>
<p id="one" class="hiddenDiv">This is paragraph 1.</p>
<p id="two" class="hiddenDiv">This is paragraph 2.</p>
<p id="three" class="hiddenDiv">This is paragraph 3.</p>
</body>
</html>

Interested in building next-gen Big Data architecture? Join our webcast on 5/24 at 9am PT. Register here: http://t.co/k5Dsfskg

Oracle Oracle

#Oracle User Groups: Are You a Member Yet? Learn more about our 870 User Groups worldwide and become a member today: http://t.co/LsktPjH5

Oracle Oracle