Ver Mensaje Individual
  #3 (permalink)  
Antiguo 20/04/2007, 18:05
Asyolath
 
Fecha de Ingreso: abril-2006
Mensajes: 80
Antigüedad: 18 años, 11 meses
Puntos: 2
Re: InsertRow() en Mozilla

Ahora he encontrado otro fallo, a la hora de eliminar las filas comienza con la primera, (la que pone nombre y email), aquí te pongo la solución (en negrita lo modificado:

<script language="javascript" type="text/javascript">

var indiceFilaFormulario=1;
function addPerson(){
myNewRow = document.getElementById("tablaFormulario").insertR ow(-1);
myNewRow.id=indiceFilaFormulario;
myNewCell=myNewRow.insertCell(0);
myNewCell.innerHTML="<td><input type='text' name='nombre["+indiceFilaFormulario+"]' id='nombresillo["+indiceFilaFormulario+"]' maxlength=5></td>";
//alert(myNewCell.innerHTML)
myNewCell=myNewRow.insertCell(1);
myNewCell.innerHTML="<td> <input type='text' name='email["+indiceFilaFormulario+"]'></td>";
myNewCell=myNewRow.insertCell(2);
var row=document.getElementById("tablaFormulario").row s;
var i = row.length-1
//if(i>1){myNewCell.innerHTML="<td><input type='button' value='Eliminar' onclick='removePerson(this.parentNode.parentNode.r owIndex)' ></td>>";}
myNewCell.innerHTML="<td><button type='button' name='enviar' onclick='removePerson(this.parentNode.parentNode.parentNode.id)'>Eliminar</button></td>";

// this hace referencia a <button>, this.parentNode es el <td> que lo contiene, this.parentNode.parentNode = myNewCell y finalmente this.parentNode.parentNode.parentNode.id= myNewRow.id


indiceFilaFormulario++;

}

function removePerson(idFila){

document.getElementById("tablaFormulario").deleteR ow(idFila);
indiceFilaFormulario--;

}

function contarTabla(){
var row=document.getElementById("tablaFormulario").row s;
var i = row.length-1
alert(i)

for(r=1;r<=i;r++){
//valores=document.formulario.nombre[r].value
valores=document.getElementById("nombresillo["+r+"]").value;
alert(valores)
//if(valores=="")alert("te faltra un campo")
}
}
</script>
[/CODE]