Foros del Web » Programando para Internet » Javascript »

creación de tabla dinámica con DOM-1

Estas en el tema de creación de tabla dinámica con DOM-1 en el foro de Javascript en Foros del Web. Hola a todos, he creado una tabla dinámica utilizando los métodos del DOM y todo funciona bien, pero solo en fire fox. En IE explorer ...
  #1 (permalink)  
Antiguo 16/10/2008, 15:46
 
Fecha de Ingreso: noviembre-2007
Mensajes: 6
Antigüedad: 16 años, 5 meses
Puntos: 0
creación de tabla dinámica con DOM-1

Hola a todos, he creado una tabla dinámica utilizando los métodos del DOM y todo funciona bien, pero solo en fire fox. En IE explorer tengo rpoblemas con los estilos, no los carga para nada, ni siquiera se da cuenta que se le han seteado unos atributos. lo peor es que en el metodo onClicl de la imagen hay un llamado a una funcion y tampoco funciona.

Alguien podría ayudarme para hacer que en IE explorer reconozca todos los atributos que se le estan seteando dinámicamente? ¿por qué no funciona el llamado a la función desde el método onclick que se establece dinámicamente?

a continuación dejo el codigo de la cabecera de la tabla, una fila de la tabla y el metodo que se llama en la imagen

//agrega una fila a la tabla en forma dinámica
function agregar(code, name, cedIden,accNbr,Amount) {
var miTBody = document.getElementById('recordsHead1');
var cantLineas = miTBody.getElementsByTagName("TR").length;
var tr = document.createElement('tr');
var textNode;

if(cantLineas == 1){
agregaTitulos();
}

//numero
var td = document.createElement('td');
td.setAttribute("width","94");
td.setAttribute("bgcolor","#E8E8E8");
td.setAttribute("class","minifont");
td.setAttribute("align","center");
if(cantLineas == 1)
textNode = document.createTextNode(cantLineas);
else
textNode = document.createTextNode(cantLineas-1);
td.appendChild(textNode);
//codigo Beneficiario
var td1 = document.createElement('td');
td1.setAttribute("width","180");
td1.setAttribute("bgcolor","#E8E8E8");
td1.setAttribute("class","minifont");
td1.setAttribute("align","center");
textNode = document.createTextNode(code);
td1.appendChild(textNode);
//nombre beneficiario
var td2 = document.createElement('td');
td2.setAttribute("width","194");
td2.setAttribute("bgcolor","#E8E8E8");
td2.setAttribute("class","minifont");
td2.setAttribute("align","center");
textNode = document.createTextNode(name);
td2.appendChild(textNode);
//cedula
var td3 = document.createElement('td');
td3.setAttribute("width","128");
td3.setAttribute("bgcolor","#E8E8E8");
td3.setAttribute("class","minifont");
td3.setAttribute("align","center");
textNode = document.createTextNode(cedIden);
td3.appendChild(textNode);
//cuenta destino
var td4 = document.createElement('td');
td4.setAttribute("width","168");
td4.setAttribute("bgcolor","#E8E8E8");
td4.setAttribute("class","minifont");
td4.setAttribute("align","center");
textNode = document.createTextNode(accNbr);
td4.appendChild(textNode);
//monto
var td5 = document.createElement('td');
td5.setAttribute("width","101");
td5.setAttribute("bgcolor","#E8E8E8");
td5.setAttribute("class","minifont");
td5.setAttribute("align","center");
textNode = document.createTextNode(Amount);
td5.appendChild(textNode);
//quitar
var td6 = document.createElement('td');
td6.setAttribute("width","97");
td6.setAttribute("bgcolor","#E8E8E8");
td6.setAttribute("class","minifont");
td6.setAttribute("align","center");

var imgRemove = document.createElement("IMG");
imgRemove.setAttribute('src','/efs/efs/grafx/btn3-delete.gif');
imgRemove.setAttribute('width','12');
imgRemove.setAttribute('height','12');
imgRemove.setAttribute('border','0');
imgRemove.setAttribute('alt','Quitar');
imgRemove.setAttribute('name','quitar');
imgRemove.setAttribute("onclick","quitarLinea(this )");
td6.appendChild(imgRemove);

tr.setAttribute("id","reg_"+cantLineas+"_"+col);
tr.appendChild(td);
tr.appendChild(td1);
tr.appendChild(td2);
tr.appendChild(td3);
tr.appendChild(td4);
tr.appendChild(td5);
tr.appendChild(td6);
document.getElementById('recordsHead1').appendChil d(tr );

col=1;
sizeRecord = 1;
document.getElementById("strCodBeneficiary").focus ();
}

//funcion que quita una linea de la tabla
function quitarLinea(elemento){
var miTD = elemento.parentNode;
var MiTR = miTD.parentNode;
var miTabla = MiTR.parentNode;
var cantLineas;

miTabla.removeChild(MiTR);
cantLineas = miTabla.getElementsByTagName("TR").length;
if(cantLineas == 2){
quitarTodos();
}
}

//funcion que crea los titulos de la tabla
function agregaTitulos(){
var miTBody = document.getElementById('recordsHead1');
var cantLineas = miTBody.getElementsByTagName("TR").length;
var tr = document.createElement('tr');
var textNode;

if(cantLineas == 1){
var td = document.createElement('td');
td.setAttribute("width","94");
td.setAttribute("bgcolor","#660000");
td.setAttribute("class","mainfontbold");
td.setAttribute("align","center");
td.setAttribute("style","color:#FFFFFF");
textNode = document.createTextNode("titulo1");
td.appendChild(textNode);
//codigo Beneficiario
var td1 = document.createElement('td');
td1.setAttribute("width","180");
td1.setAttribute("bgcolor","#660000");
td1.setAttribute("class","mainfontbold");
td1.setAttribute("align","center");
td1.setAttribute("style","color:#FFFFFF");
textNode = document.createTextNode("titulo2");
td1.appendChild(textNode);
//nombre beneficiario
var td2 = document.createElement('td');
td2.setAttribute("width","194");
td2.setAttribute("bgcolor","#660000");
td2.setAttribute("class","mainfontbold");
td2.setAttribute("align","center");
td2.setAttribute("style","color:#FFFFFF");
textNode = document.createTextNode("titulo3");
td2.appendChild(textNode);
//cedula
var td3 = document.createElement('td');
td3.setAttribute("width","128");
td3.setAttribute("bgcolor","#660000");
td3.setAttribute("class","mainfontbold");
td3.setAttribute("align","center");
td3.setAttribute("style","color:#FFFFFF");
textNode = document.createTextNode("titulo4");
td3.appendChild(textNode);
//cuenta destino
var td4 = document.createElement('td');
td4.setAttribute("width","168");
td4.setAttribute("bgcolor","#660000");
td4.setAttribute("class","mainfontbold");
td4.setAttribute("align","center");
td4.setAttribute("style","color:#FFFFFF");
textNode = document.createTextNode("titulo5");
td4.appendChild(textNode);
//monto
var td5 = document.createElement('td');
td5.setAttribute("width","101");
td5.setAttribute("bgcolor","#660000");
td5.setAttribute("class","mainfontbold");
td5.setAttribute("align","center");
td5.setAttribute("style","color:#FFFFFF");
textNode = document.createTextNode("titulo6");
td5.appendChild(textNode);
//quitar
var td6 = document.createElement('td');
td6.setAttribute("width","97");
td6.setAttribute("bgcolor","#660000");
td6.setAttribute("class","mainfontbold");
td6.setAttribute("align","center");
td6.setAttribute("style","color:#FFFFFF");
textNode = document.createTextNode("titulo7");
td6.appendChild(textNode);

tr.setAttribute("id","titulos");
tr.appendChild(td);
tr.appendChild(td1);
tr.appendChild(td2);
tr.appendChild(td3);
tr.appendChild(td4);
tr.appendChild(td5);
tr.appendChild(td6);
miTBody.appendChild(tr );
}
}

este es el codigo que tiene la tabla en el html
<table width="100%" id="recordsHead" border="0" cellspacing="0" cellpadding="0">
<tbody id="recordsHead1">
<tr id="miSeparador">
<td width="94" class="mainfontbold" >&nbsp;</td>
<td width="180" class="mainfontbold" >&nbsp;</td>
<td width="194" class="mainfontbold" >&nbsp;</td>
<td width="128" class="mainfontbold" >&nbsp;</td>
<td width="168" class="mainfontbold" >&nbsp;</td>
<td width="101" class="mainfontbold" >&nbsp;</td>
<td width="97" class="mainfontbold" >&nbsp;</td>
</tr>
</tbody>
</table>
leas agradecería si alguien puede ayudarme con esto.
  #2 (permalink)  
Antiguo 17/10/2008, 09:12
Avatar de JavierB
Colaborador
 
Fecha de Ingreso: febrero-2002
Ubicación: Madrid
Mensajes: 25.052
Antigüedad: 22 años, 2 meses
Puntos: 772
Respuesta: creación de tabla dinámica con DOM-1

Hola angel3d3

Prueba poniéndolo así:

Código javascript:
Ver original
  1. td.style.width = '94px';
  2. td.style.background = '#660000';
  3. td.className = 'mainfontbold';

Saludos,
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 16:28.