Ver Mensaje Individual
  #1 (permalink)  
Antiguo 13/05/2010, 17:38
serbarmax
 
Fecha de Ingreso: enero-2003
Mensajes: 120
Antigüedad: 21 años, 4 meses
Puntos: 0
Pregunta Incompatbilidad Firefox TypeError: tbl.rows is not a function

Hola:

Tengo el siguiente código que me anda en IE y Chrome pero no en Firefox.
Es manejo de tablas con javascript, y esta función sirve para agregar filas al final de la tabla.

Qué puede ser? Existirá alguna instrucción alternativa compatible?

Código:
var rows_limit = 0; // Set to 0 to disable limitation

function addRow(table_id, id)
{
var initial_count = new Array();
var rows_limit = 0; // Set to 0 to disable limitation
var indice= document.formul.Practica.selectedIndex;
var valor = '<div align="center">'+document.formul.Practica.options[indice].value+"</div>";
var texto = document.formul.Practica.options[indice].text;
var canti = '<div align="center">'+document.formul.cantidad.value+"</div>";
var indice= document.formul.Paciente.selectedIndex;
var paciente = document.formul.Paciente.options[indice].value;
var indice= document.formul.Medico.selectedIndex;
var medico = document.formul.Medico.options[indice].value;
var indice= document.formul.obrasocial.selectedIndex;
var osocial = document.formul.obrasocial.options[indice].value;
var chafe    = document.formul.fecha.value;
var tbl       = document.getElementById(table_id);
AQUI SUPUESTAMENTE SE PRODUCE EL PROBLEMA
-------------------------------------------------------------------
var rows_count = tbl.rows.length;
--------------------------------------------------------------------
if (initial_count[table_id] == undefined)
{
    // if it is first adding in this table setting initial rows count
    initial_count[table_id] = rows_count;
}
// determining real count of added fields

var tFielsNum = rows_count - initial_count[table_id];
if (rows_limit!=0 && tFielsNum >= rows_limit) return false;
//var input = '<input type="text" name="postvar[]" style="width:100%;"/>'; removeRow('mytable',this.parentNode.parentNode,<? echo $row2["Id"]; ?>)
 var remove= '<input type="button" value="Borrar" onclick="removeRow(\'mytable\',this.parentNode.parentNode,'+id+');" />';
//alert(remove);
try {
    var newRow = tbl.insertRow(rows_count);
    tbl.rows(rows_count).style.backgroundColor = "#FFCC66";
    var newCell = newRow.insertCell(0);
    newCell.innerHTML = valor;
    var newCell = newRow.insertCell(1);
    newCell.innerHTML = texto;
    var newCell = newRow.insertCell(2);
    newCell.innerHTML = canti;
    var newCell = newRow.insertCell(3);
    newCell.innerHTML = "&nbsp;";
    var newCell = newRow.insertCell(4);
    newCell.innerHTML = remove;
} catch (ex) {
    //if exception occurs
    alert(ex);
}
}
No me dice el renglón donde da el error pero la primera coincidencia de la parte descripta es la línea:

var rows_count = tbl.rows.length;

"TypeError: tbl.rows is not a function"

Ayuda por favor. Gracias.
__________________
Sergio.