Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Show layer onClick or onSubmit

Status
Not open for further replies.

nrenfree

Programmer
Apr 14, 2006
5
US
I have two layers on a page. One layer contains a form with a set of radio buttons. When I click a radio button, I want to submit the form which sends the value of the radio button clicked and SHOW another layer that has a dropdown menu on it that shows a subset of a database column depending on the radio button clicked.

Everything works swell as long as I have everything shown all the time. What I want is for the drop-down menu to be hidden when the page loads and then appear when a radio button is clicked.

If I put the "Show Layer" behavior on each radio button, I can see the drop-down for a moment and then it goes away. If I put the "Show Layer" behavior on the "OnSubmit" of the form, I don't see the other layer at all.

What simple thing have a I missed?

Thank you for your help,

Nancy
 
You should be able to use show hide layers to achieve this. Have a look at the code below in a browser.
Code:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
<style type="text/css">
<!--
#Layer1 {
	position:absolute;
	width:200px;
	height:115px;
	z-index:1;
	background-color: #FF0000;
	visibility: hidden;
}
#Layer2 {
	position:absolute;
	width:200px;
	height:115px;
	z-index:2;
	left: 234px;
	top: 94px;
	background-color: #0000FF;
	visibility: hidden;
}
-->
</style>
<script type="text/javascript">
<!--
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}
//-->
</script>
</head>

<body>
<form name="form1" method="post" action="">
  <p>
    <input name="radiobutton" type="radio" onClick="MM_showHideLayers('Layer1','','show','Layer2','','hide')" value="layer1">
</p>
  <p>
    <input name="radiobutton" type="radio" onClick="MM_showHideLayers('Layer1','','hide','Layer2','','show')" value="layer2">
</p>
  <div id="Layer1"></div>
  <div id="Layer2"></div>
  <p>&nbsp;</p>
</form>
</body>
</html>

[Peace][Pipe]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top