Ver Mensaje Individual
  #1 (permalink)  
Antiguo 13/03/2009, 03:13
desinglive
 
Fecha de Ingreso: agosto-2008
Ubicación: León
Mensajes: 28
Antigüedad: 16 años, 6 meses
Puntos: 0
cerrar tablas al abrir otras [importante]

Hola necesito saber como puedo cerrar tablas, al abrir otras. aqui os pongo el codigo, se abren las 4 si las pulso, pero yo quiero que se cierren todas cuando abra una, y si abro otra que se cierre esa.

<script language="javascript">
function cambiarDisplay(id) {
if (!document.getElementById) return false;
fila = document.getElementById(id);
if (fila.style.display != "none") {
fila.style.display = "none";
} else {
fila.style.display = "";
}
}
</script></head>

<body>
<table align="center">
<tr id="row1" onClick="cambiarDisplay('row2')">
<td width="55"><div align="center"><strong>Prueba1</strong></div></td>
</tr>
<tr id="row2" onClick="cambiarDisplay('row2')" style="display:none">
<td><div align="center">texto Prueba 1 </div></td>
</tr>
</table>
<table align="center">
<tr id="row11" onClick="cambiarDisplay('row22')">
<td width="55"><div align="center"><strong>Prueba2</strong></div></td>
</tr>
<tr id="row22" onClick="cambiarDisplay('row22')" style="display:none">
<td><div align="center">texto Prueba 2 </div></td>
</tr>
</table>
<table align="center">
<tr id="row111" onClick="cambiarDisplay('row222')">
<td width="55"><div align="center"><strong>Prueba3</strong></div></td>
</tr>
<tr id="row222" onClick="cambiarDisplay('row222')" style="display:none">
<td><div align="center">texto Prueba 3 </div></td>
</tr>
</table>
<table align="center">
<tr id="row1111" onClick="cambiarDisplay('row2222')">
<td width="55"><div align="center"><strong>Prueba4</strong></div></td>
</tr>
<tr id="row2222" onClick="cambiarDisplay('row2222')" style="display:none">
<td><div align="center">texto Prueba 4 </div></td>
</tr>
</table>
</body>
</html>

Última edición por desinglive; 13/03/2009 a las 03:15 Razón: poner el codigo