hola a todos..
tengo un codigo que esta vinculado con un boton "<input type="button" name="Submit" value="Agregar Foto" onClick="Agregar()">" en un form.. que crea 2 campos de texto cada vez que se activa...
me gustaria ahora tener una funcion para BORRAR los ultimos 2 campos de texto CREADOS.. como puedo hacer eso ???
este es el codigo que crea los campos
Código HTML:
<script>
Num=0;
function Agregar(){
obj=document.getElementById('tabla');
f=document.getElementById('fila');
Num++;
elTr=document.createElement('tr');
elTd=document.createElement('td');
elTd.innerHTML='Foto '+Num+':';
elTr.appendChild(elTd);
elTd=document.createElement('td');
elem=document.createElement('input');
elem.type='textarea';
elem.name='foto[]'+Num;
elemTxt=document.createElement('input');
elemTxt.type='textarea';
elemTxt.name='txt[]'+Num; //esto lo agregué
elemTxt.size='30';
elTd.appendChild(elem);
elTd.appendChild(elemTxt);
elTr.appendChild(elTd);
obj.insertBefore(elTr,f)
}
function borrar2() NO SE COMO HACER ESTO !!!
{
var x = document.getElementById("obj");
x.removeChild(x.lastChild);
x.removeChild(x.lastChild);
x.removeChild(x.lastChild);
}
</script>