no funciona?
Publicado por gerardo medina (7 intervenciones) el 21/12/2007 19:29:37
Hola a todos!!!, esto es una página que agrega un nuevo ítem dentro de una tabla...
El detalle, como siempre en Firefox, funciona de lo correcto. Menos en IE....
Lo que esta el código de la function "insertarFila()" sin comentario sería la solución DOM, lo otro que esta como comentario es válido, si lo cancelamos el otro.
Pero el detalle aquí es eso!, en el alert que te muestra del innerHTML, es muy distinto.
además el fin de esto es... PORQUE NO FUNCIONA EN IEv6.0, Según "alert" debe mostrar, pero nada.... CUAL ES EL ERROR? Y COMO LOGRAR PARA QUE FUNCIONE
PAG. HTML
*************
<!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>Documento sin título</title>
<script>
function insertarFila()
{
fila = document.createElement("tr");
columnas = document.createElement("td");
columnas.setAttribute("width", "144px");
input = document.createElement("input");
input.setAttribute("type","text");
input.setAttribute("name", "txtNombres[]");
input.setAttribute("class","casilla")
columnas.appendChild(input)
fila.appendChild(columnas)
columnas = document.createElement("td");
columnas.setAttribute("width", "144px");
input = document.createElement("input");
input.setAttribute("type","text");
input.setAttribute("name", "txtApellidos[]");
input.setAttribute("class","casilla")
columnas.appendChild(input)
fila.appendChild(columnas)
columnas = document.createElement("td");
columnas.setAttribute("width", "144px");
input = document.createElement("input");
input.setAttribute("type","text");
input.setAttribute("name", "txtFechaNacimiento[]");
input.setAttribute("class","casilla")
columnas.appendChild(input)
fila.appendChild(columnas)
columnas = document.createElement("td");
columnas.setAttribute("width", "144px");
input = document.createElement("input");
input.setAttribute("type","text");
input.setAttribute("name", "txtPartida[]");
input.setAttribute("class","casilla")
columnas.appendChild(input)
fila.appendChild(columnas)
columnas = document.createElement("td");
columnas.setAttribute("width", "144");
input = document.createElement("input");
input.setAttribute("type","text");
input.setAttribute("name", "txtDomicilio[]");
input.setAttribute("class","casilla")
input.setAttribute("style","width:294px;");
columnas.appendChild(input)
fila.appendChild(columnas)
/*
fila = document.createElement("tr");
columnas = document.createElement("td");
columnas.setAttribute("width", "144px");
columnas.innerHTML = "<input type='text' name='txtNombres[]' class='casilla'/>";
fila.appendChild(columnas)
columnas = document.createElement("td");
columnas.setAttribute("width", "144px");
columnas.innerHTML = "<input type='text' name='txtApellidos[]' class='casilla'/>";
fila.appendChild(columnas)
columnas = document.createElement("td");
columnas.setAttribute("width", "144px");
columnas.innerHTML = "<input type='text' name='txtFechaNacimiento[]' class='casilla'/>";
fila.appendChild(columnas)
columnas = document.createElement("td");
columnas.setAttribute("width", "144px");
columnas.innerHTML = "<input type='text' name='txtPartida[]' class='casilla'/>";
fila.appendChild(columnas)
columnas = document.createElement("td");
columnas.setAttribute("width", "144");
columnas.innerHTML = "<input type='text' name='txtDomicilio[]' class='casilla' style='width:294px;'/>";
fila.appendChild(columnas)
*/
document.getElementById('tblHijos').appendChild(fila)
alert(document.getElementById('tblHijos').innerHTML)
}
</script>
<style type="text/css">
.casilla
{
border:0px;
}
</style>
</head>
<body style="font-family:Arial, Helvetica, sans-serif">
<form>
<input type="button" onclick="insertarFila()" value="Agregar"/>
<table cellpadding="0" cellspacing="0" style="font-size:12px;" border="1" id="tblHijos">
<tr style="background-color:#0066FF; color:#FFFFFF;" align="center">
<td width="144px" height="26">Nombres</td>
<td width="144px">Apellidos </td>
<td width="144px">Fecha Nacimiento </td>
<td width="144px">Partida Nacimiento </td>
<td width="296px">Domicilio</td>
</tr>
</table>
<div>
<table border="1" cellpadding="0" cellspacing="0" style="font-size:12px" >
<tr>
<tr valign='top'>
<td width='144'><input type='text' name='txtNombres[]' class='casilla'/></td>
<td width='144'><input type='text' name='txtApellidos[]' class='casilla'/></td>
<td width='144'><input type='text' name='txtFechaNacimiento[]' class='casilla'/> </td>
<td width='144'><input type='text' name='txtPartida[]' class='casilla'/></td>
<td width='296'><input type='text' name='txtDomicilio[]' class='casilla' style='width:294px;'/></td>
</tr>
</table>
</div>
</form>
</body>
</html>
El detalle, como siempre en Firefox, funciona de lo correcto. Menos en IE....
Lo que esta el código de la function "insertarFila()" sin comentario sería la solución DOM, lo otro que esta como comentario es válido, si lo cancelamos el otro.
Pero el detalle aquí es eso!, en el alert que te muestra del innerHTML, es muy distinto.
además el fin de esto es... PORQUE NO FUNCIONA EN IEv6.0, Según "alert" debe mostrar, pero nada.... CUAL ES EL ERROR? Y COMO LOGRAR PARA QUE FUNCIONE
PAG. HTML
*************
<!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>Documento sin título</title>
<script>
function insertarFila()
{
fila = document.createElement("tr");
columnas = document.createElement("td");
columnas.setAttribute("width", "144px");
input = document.createElement("input");
input.setAttribute("type","text");
input.setAttribute("name", "txtNombres[]");
input.setAttribute("class","casilla")
columnas.appendChild(input)
fila.appendChild(columnas)
columnas = document.createElement("td");
columnas.setAttribute("width", "144px");
input = document.createElement("input");
input.setAttribute("type","text");
input.setAttribute("name", "txtApellidos[]");
input.setAttribute("class","casilla")
columnas.appendChild(input)
fila.appendChild(columnas)
columnas = document.createElement("td");
columnas.setAttribute("width", "144px");
input = document.createElement("input");
input.setAttribute("type","text");
input.setAttribute("name", "txtFechaNacimiento[]");
input.setAttribute("class","casilla")
columnas.appendChild(input)
fila.appendChild(columnas)
columnas = document.createElement("td");
columnas.setAttribute("width", "144px");
input = document.createElement("input");
input.setAttribute("type","text");
input.setAttribute("name", "txtPartida[]");
input.setAttribute("class","casilla")
columnas.appendChild(input)
fila.appendChild(columnas)
columnas = document.createElement("td");
columnas.setAttribute("width", "144");
input = document.createElement("input");
input.setAttribute("type","text");
input.setAttribute("name", "txtDomicilio[]");
input.setAttribute("class","casilla")
input.setAttribute("style","width:294px;");
columnas.appendChild(input)
fila.appendChild(columnas)
/*
fila = document.createElement("tr");
columnas = document.createElement("td");
columnas.setAttribute("width", "144px");
columnas.innerHTML = "<input type='text' name='txtNombres[]' class='casilla'/>";
fila.appendChild(columnas)
columnas = document.createElement("td");
columnas.setAttribute("width", "144px");
columnas.innerHTML = "<input type='text' name='txtApellidos[]' class='casilla'/>";
fila.appendChild(columnas)
columnas = document.createElement("td");
columnas.setAttribute("width", "144px");
columnas.innerHTML = "<input type='text' name='txtFechaNacimiento[]' class='casilla'/>";
fila.appendChild(columnas)
columnas = document.createElement("td");
columnas.setAttribute("width", "144px");
columnas.innerHTML = "<input type='text' name='txtPartida[]' class='casilla'/>";
fila.appendChild(columnas)
columnas = document.createElement("td");
columnas.setAttribute("width", "144");
columnas.innerHTML = "<input type='text' name='txtDomicilio[]' class='casilla' style='width:294px;'/>";
fila.appendChild(columnas)
*/
document.getElementById('tblHijos').appendChild(fila)
alert(document.getElementById('tblHijos').innerHTML)
}
</script>
<style type="text/css">
.casilla
{
border:0px;
}
</style>
</head>
<body style="font-family:Arial, Helvetica, sans-serif">
<form>
<input type="button" onclick="insertarFila()" value="Agregar"/>
<table cellpadding="0" cellspacing="0" style="font-size:12px;" border="1" id="tblHijos">
<tr style="background-color:#0066FF; color:#FFFFFF;" align="center">
<td width="144px" height="26">Nombres</td>
<td width="144px">Apellidos </td>
<td width="144px">Fecha Nacimiento </td>
<td width="144px">Partida Nacimiento </td>
<td width="296px">Domicilio</td>
</tr>
</table>
<div>
<table border="1" cellpadding="0" cellspacing="0" style="font-size:12px" >
<tr>
<tr valign='top'>
<td width='144'><input type='text' name='txtNombres[]' class='casilla'/></td>
<td width='144'><input type='text' name='txtApellidos[]' class='casilla'/></td>
<td width='144'><input type='text' name='txtFechaNacimiento[]' class='casilla'/> </td>
<td width='144'><input type='text' name='txtPartida[]' class='casilla'/></td>
<td width='296'><input type='text' name='txtDomicilio[]' class='casilla' style='width:294px;'/></td>
</tr>
</table>
</div>
</form>
</body>
</html>
Valora esta pregunta


0