Ver Mensaje Individual
  #1 (permalink)  
Antiguo 23/07/2007, 17:53
Avatar de hgp147
hgp147
 
Fecha de Ingreso: diciembre-2006
Ubicación: Buenos Aires, Argentina
Mensajes: 980
Antigüedad: 17 años, 4 meses
Puntos: 36
Pregunta Mostrar/ocultar capas

Hola, encontre un código que sirve para mostrar y ocultar capas, funciona perfectamente, pero lo quiero saber si en vez de tener una funcion llamada mostrar1, mostrar2 y mostrar3 (lo mismo con la funcion ocultar), podria tener una sola funcion llamada por ejemplo mostrar y que sirva para las 3 capas.

Código HTML:
<html>
<head>

<script>

OCULTO="none";
VISIBLE="block";
	
function mostrar1(blo) {
  document.getElementById(blo).style.display=VISIBLE;
  document.getElementById('ver_off1').style.display=VISIBLE;
  document.getElementById('ver_on1').style.display=OCULTO;
}
 
function ocultar1(blo) {
  document.getElementById(blo).style.display=OCULTO;
  document.getElementById('ver_off1').style.display=OCULTO;
  document.getElementById('ver_on1').style.display=VISIBLE;
}
</script>

<script>

OCULTO="none";
VISIBLE="block";
	
function mostrar2(blo) {
  document.getElementById(blo).style.display=VISIBLE;
  document.getElementById('ver_off2').style.display=VISIBLE;
  document.getElementById('ver_on2').style.display=OCULTO;
}
 
function ocultar2(blo) {
  document.getElementById(blo).style.display=OCULTO;
  document.getElementById('ver_off2').style.display=OCULTO;
  document.getElementById('ver_on2').style.display=VISIBLE;
}
</script>


<script>

OCULTO="none";
VISIBLE="block";
	
function mostrar3(blo) {
  document.getElementById(blo).style.display=VISIBLE;
  document.getElementById('ver_off3').style.display=VISIBLE;
  document.getElementById('ver_on3').style.display=OCULTO;
}
 
function ocultar3(blo) {
  document.getElementById(blo).style.display=OCULTO;
  document.getElementById('ver_off3').style.display=OCULTO;
  document.getElementById('ver_on3').style.display=VISIBLE;
}
</script>



</head>
<body>


<div id="ver_on1"><a href="#" onclick="mostrar1('bloque1'); return false">Mostrar bloque1</a></div>

<div id="ver_off1" style="display: none"><a href="#" onclick="ocultar1('bloque1'); return false">Ocultar bloque1</a></div>

<div id="bloque1" style="display: none">
<p>Contenido bloque1</p>
</div>




<div id="ver_on2"><a href="#" onclick="mostrar2('bloque2'); return false">Mostrar bloque2</a></div>

<div id="ver_off2" style="display: none"><a href="#" onclick="ocultar2('bloque2'); return false">Ocultar bloque2</a></div>

<div id="bloque2" style="display: none">
<p>Contenido bloque2</p>
</div>






<div id="ver_on3"><a href="#" onclick="mostrar3('bloque3'); return false">Mostrar bloque3</a></div>

<div id="ver_off3" style="display: none"><a href="#" onclick="ocultar3('bloque3'); return false">Ocultar bloque3</a></div>

<div id="bloque3" style="display: none">
<p>Contenido bloque3</p>
</div>




</body>
</html> 
Gracias