Ver Mensaje Individual
  #3 (permalink)  
Antiguo 30/11/2007, 10:50
Avatar de JavierB
JavierB
Colaborador
 
Fecha de Ingreso: febrero-2002
Ubicación: Madrid
Mensajes: 25.052
Antigüedad: 23 años, 1 mes
Puntos: 772
Re: innerHTML? o es con otra función?

Hola 7th_Sign

Me he entretenido un rato haciendo este código, espero que te sirva:

Código PHP:
<html>
<
head>
<
script type="text/javascript">
function 
anadir(obj) {
  
fila obj.parentNode.parentNode;
  
tabla fila.parentNode;
  
lineas tabla.getElementsByTagName('tr');
  
// averiguar fila pulsada
  
for (i=0ele lineas[i]; i++)
    if (
ele==fila) break;
  
// crear fila, celdas y botón
  
document.createElement('tr');
  
f.appendChild(document.createElement('td'));
  
c.innerHTML '---';
  
f.appendChild(document.createElement('td'));
  
document.createElement('input');
  
b.setAttribute('type','button');
  
b.onclick = function() {anadir(this)}
  
c.appendChild(b);
  
  if (
i==lineas.length-1)
    
tabla.appendChild(f);
  else
    
tabla.insertBefore(f,lineas[i+1]);
}
</script>
</head>
<body>
<table>
<tbody>
<tr><td>-1-</td><td><input type="button" onclick="anadir(this)" /></td></tr>
<tr><td>-2-</td><td><input type="button" onclick="anadir(this)" /></td></tr>
<tr><td>-3-</td><td><input type="button" onclick="anadir(this)" /></td></tr>
</tbody>
</table>
</body>
</html> 
Saludos,