Ver Mensaje Individual
  #7 (permalink)  
Antiguo 18/07/2007, 09:01
marcospuig
 
Fecha de Ingreso: febrero-2007
Mensajes: 138
Antigüedad: 18 años
Puntos: 0
Re: Reubicar input

Si, funciona, muchisssimas gracias

Pero hay 1 pequeño problema, y es que ahora el borrar no me funciona. El script con tu explicación me ha quedado así:


<script type="text/javascript">

num=0;
function crearTitulacion(obj) {

papa = obj.parentNode;
hermano = obj.nextSibling;

num++;
fi = document.getElementById('f1');
contenedor = document.createElement('div');
contenedor.id = 'div'+num;
if (hermano == undefined)
papa.appendChild(ele)
else
papa.insertBefore(contenedor, hermano)


// fi.appendChild(contenedor);

ele = document.createElement('input');
ele.type = 'text';
ele.name = 'titulacion'+num;
ele.size = '40';
//contenedor.appendChild(ele);
if (hermano == undefined)
papa.appendChild(ele)
else
papa.insertBefore(ele, hermano)


ele = document.createElement('input');
ele.type = 'button';
ele.value = 'Borrar';
ele.name = 'div'+num;
ele.onclick = function () {borrar(this.name)}
// contenedor.appendChild(ele);
if (hermano == undefined)
papa.appendChild(ele)
else
papa.insertBefore(ele, hermano)

}
function borrar(obj) {
fi = document.getElementById('f1');
fi.removeChild(document.getElementById(obj));
}

</script>



Pero ahora cuando pulso en el botón borrar no me hace nada