Ver Mensaje Individual
  #2 (permalink)  
Antiguo 22/07/2008, 23:33
Avatar de Panino5001
Panino5001
Me alejo de Omelas
 
Fecha de Ingreso: mayo-2004
Ubicación: -34.637167,-58.462984
Mensajes: 5.148
Antigüedad: 20 años
Puntos: 834
Respuesta: obtener id de forma atomática para getElementById

Lo mejor es no usar el id en este caso (no siempre conviene referenciar usando id). Una alternativa:
Código PHP:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<
html xmlns="http://www.w3.org/1999/xhtml">
<
head>
<
meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<
title></title>
<
script type="text/javascript">
function 
shToggle(obj) {
if (
obj.nextSibling.style.display == "none")
obj.nextSibling.style.display "block"
else
obj.nextSibling.style.display "none"
}
</script>
</head>

<body>
<table>
  <tr>
    <td>
    <a href="javascript:void(0);" onclick="shToggle(this); return false;">[Mostrar|Ocultar]</a><div id="id1" style="display:none;">contenido</div>
   </td>
  </tr>
  <tr>
    <td>
    <a href="javascript:void(0);" onclick="shToggle(this); return false;">[Mostrar|Ocultar]</a><div id="id2" style="display:none;">contenido</div>
   </td>
  </tr>
</table>
</body>
</html>