Link to home
Start Free TrialLog in
Avatar of Stefan Motz
Stefan MotzFlag for United States of America

asked on

JavaScript Show/Hide

Hi Experts,
I would like to add two more radio buttons so that I can display 333 and 444 when they are clicked.

Thanks for your help

<html>
<head>
<script type="text/javascript">
	function showHide(id,toShow){
		$(id).style.display = toShow;
	}
	function $(id){
		return document.getElementById(id);
	}
	function removeNameIfParentDivHidden() {
		var divs = document.getElementsByTagName("div");
		for(var i=0;i<divs.length;i++) {
			if(divs[i].style.display == "none") {
				var e = divs[i].getElementsByTagName("*");
				for(var j=0;j<e.length;j++) {
					if(e[j].name && e[j].name.length>0) {

						e[j].name = "";
					}
				}
			}
		}
	}
</script>
</head>
<body>
<br />

<input type="radio" name="SearchArea" onclick="showHide('111','block');showHide('222','none');">
<input type="radio" name="SearchArea" onclick="showHide('111','none');showHide('222','block');">


<div align="center" id="111" style="display: none">111</div>
<div align="center" id="222" style="display: none">222</div>
<div align="center" id="333" style="display: none">333</div>
<div align="center" id="444" style="display: none">444</div>


</body>
</html>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Rainer Jeschor
Rainer Jeschor
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Stefan Motz

ASKER

Thank you very much for your quick response. This is perfect!