Ver Mensaje Individual
  #1 (permalink)  
Antiguo 03/12/2007, 15:18
7th_Sign
 
Fecha de Ingreso: noviembre-2007
Mensajes: 35
Antigüedad: 17 años, 5 meses
Puntos: 0
insertBefore no me funciona en IE, que anda mal?

Hola Foro,

Esto de Javascript me esta dando dolores de cabeza :P, con su ayuda he hecho una rutina para agregar celdas a una tabla y funciona muy bien en Firefox, pero el problema viene cuando abro con el Internet Explorer, ya que marca un error, le active la herramienta para hacer debug y el error señala a la línea dónde esta el insertBefore.

Según yo todo el código esta normalito o habra por ahí algún parametro que no este bien puesto?

les dejo el código de la función JS
Código:
	var count=2;

	function addRows(id,mitabla,button){

		fila = mitabla.parentNode.parentNode;
		tbody = fila.parentNode;
		lineas = tbody.getElementsByTagName('tr');		
               
        var row = document.createElement('TR');
		row.className="background_ppm";

		var tn1 = document.createElement("TD"); 
		tn1.innerHTML="";
		tn1.setAttribute("colspan","8");
		    
		var tn2 = document.createElement("TD"); 
		if(button==1){
			tn2.innerHTML="<input type='button' onclick='removeRows(this)' value='&nbsp;-'>";
		}
		else{
			tn2.innerHTML="";
		}
		    
        var t0 = document.createElement("TD"); 
        celda0 =document.createElement("input");
        celda0.setAttribute("type","text");
        celda0.setAttribute("name","peso_charola_"+id+"[]");
        celda0.setAttribute("id","peso_charola_"+id);
        celda0.setAttribute("size","4");
        celda0.setAttribute("maxlength","8");
        celda0.setAttribute("style","text-align:right");
        celda0.setAttribute("onchange","calcula_ppm(" + id + "," + count + ")");
        celda0.setAttribute("align","center");
		t0.appendChild(celda0)
				
		var t1 = document.createElement("TD"); 
        celda1 =document.createElement("input");
        celda1.setAttribute("type","text");
        celda1.setAttribute("name","tot1_"+id+"[]");
        celda1.setAttribute("id","tot1_"+id);
        celda1.setAttribute("size","4");
        celda1.setAttribute("maxlength","8");
        celda1.setAttribute("style","text-align:right");
        celda1.setAttribute("onchange","calcula_ppm(" + id + "," + count + ")");
        celda1.setAttribute("align","center");
		t1.appendChild(celda1)
		
        var t2= document.createElement("TD"); 
        celda2 =document.createElement("input");
        celda2.setAttribute("type","text");
        celda2.setAttribute("name","tot2_"+id+"[]");
        celda2.setAttribute("id","tot2_"+id);
        celda2.setAttribute("size","4");
        celda2.setAttribute("maxlength","8");
        celda2.setAttribute("style","text-align:right");
        celda2.setAttribute("onchange","calcula_ppm(" + id + "," + count + ")");
        celda2.setAttribute("align","center");
		t2.appendChild(celda2)
		
        var t3= document.createElement("TD"); 
        celda3 =document.createElement("input");
        celda3.setAttribute("type","text");
        celda3.setAttribute("name","peso_pvc_"+id+"[]");
        celda3.setAttribute("id","peso_pvc_"+id);
        celda3.setAttribute("size","4");
        celda3.setAttribute("maxlength","8");
        celda3.setAttribute("style","text-align:right");
        celda3.setAttribute("onchange","calcula_ppm(" + id + "," + count + ")");
        celda3.setAttribute("align","center");
		t3.appendChild(celda3)
        

        var t4= document.createElement("TD"); 
        celda4 =document.createElement("input");
        celda4.setAttribute("type","text");
        celda4.setAttribute("name","ppm_"+id+"[]");
        celda4.setAttribute("id","ppm_"+id);
        celda4.setAttribute("size","4");
        celda4.setAttribute("readonly","");
        celda4.setAttribute("style","text-align:right; background-color:#9F9F9F");
        celda4.setAttribute("onchange","calcula_ppm(" + id + "," + count + ")");
        celda4.setAttribute("align","center");
		t4.appendChild(celda4)

		     
        
        
     	row.appendChild(tn1);  
        row.appendChild(t0);        
    	row.appendChild(t1);
   	    row.appendChild(t2);
        row.appendChild(t3);
        row.appendChild(t4);
		row.appendChild(tn2);

		for (i=0; ele = lineas[i]; i++){
		    if (ele==fila){
				break;
			}
		}    
		
		if (i==lineas.length-1){
			tbody.appendChild(row);
		}
		else{
			tbody.insertBefore(row,lineas[i+2]);	
		}

        count++;
   }
Qué anda?