
November 4th, 2009, 04:53 AM
|
 |
Moderator
|
|
Join Date: Mar 2006
Location: South Wales
|
|
Quote: | Originally Posted by naresbiz1 I have a dropdown having four menu list under that there are four div tags when dropdown onchange it should enable one div tag and disable other three like that for every change one should enable remaining all should should Disable with out displaying in page...........please any body can help......? |
As Aashish says, did you want to enable/disable the divs or hide/show them?
Heres a simple example that hides the ones that aren't selected:
Code:
<script>
var browserType;
if (document.layers) {browserType = "nn4"}
if (document.all) {browserType = "ie"}
if (window.navigator.userAgent.toLowerCase().match("gecko")) {
browserType= "gecko"
}
function hide(whichelement) {
if (browserType == "gecko" )
document.poppedLayer =
eval('document.getElementById(whichelement)');
else if (browserType == "ie")
document.poppedLayer =
eval('document.getElementById(whichelement)');
else
document.poppedLayer =
eval('document.layers[whichelement]');
document.poppedLayer.style.display = "none";
}
function show(whichelement) {
if (browserType == "gecko" )
document.poppedLayer =
eval('document.getElementById(whichelement)');
else if (browserType == "ie")
document.poppedLayer =
eval('document.getElementById(whichelement)');
else
document.poppedLayer =
eval('document.layers[whichelement]');
document.poppedLayer.style.display = "inline";
}
function doHideShow(theDiv){
for(var a=1;a<=4;a++){
if(a==theDiv){
show("div"+a);
}else{
hide("div"+a);
}
}
}
</script>
<html>
<head>
<title></title>
</head>
<body>
<form name="form1">
<select name="showhide" onchange="doHideShow(document.form1.showhide.selectedIndex+1 );">
<option value="1">Div 1</option>
<option value="2">Div 2</option>
<option value="3">Div 3</option>
<option value="4">Div 4</option>
</select>
<br>
<div id="div1" style="display: inline; border-width: 1px; border-style: none;">
<layer></layer>
This is Div 1
</div>
<br>
<div id="div2" style="display: none; border-width: 1px; border-style: none;">
<layer></layer>
This is Div 2
</div>
<br>
<div id="div3" style="display: none; border-width: 1px; border-style: none;">
<layer></layer>
This is Div 3
</div>
<br>
<div id="div4" style="display: none; border-width: 1px; border-style: none;">
<layer></layer>
This is Div 4
</div>
</form>
</body>
</html>
|