Hola, este es el codigo de la función add()
Código Javascript
:
Ver originalfunction add() {
tabla = document.getElementById('productos');
n++;
document.getElementById('numfilas').value=n;
document.getElementById('aceptar').style.display="block";
fila = document.createElement('tr');
var actual=n;
celda = document.createElement('td');
fila.appendChild(celda);
code=document.createElement('input');
code.type='text';
code.name='cod_'+n;
code.id='cod_'+n;
code.size='5';
code.maxLength='4';
//code.onchange = function() {MostrarConsultaProducto('consulta2.php?id='+document.getElementById('cod_'+actual).value,'desc_'+actual,"emb_"+actual,"vund_"+actual,actual);};
//code.onkeydown = function() {key('consulta2.php','cod_'+actual,'desc_'+actual,"emb_"+actual,"vund_"+actual,actual);};
funcion='return key(event,"consulta2.php","cod_'+actual+'","desc_'+actual+'","emb_'+actual+'","vund_'+actual+'",'+actual+');';
code.setAttribute('onKeyDown', funcion);
//code.onkeyup = function() {key('consulta2.php','cod_'+actual,'desc_'+actual);pasarEnter(this.id);};
celda.appendChild(code);
celda = document.createElement('td');
fila.appendChild(celda);
desc=document.createElement('input');
desc.type='text';
desc.name='desc_'+n;
desc.id='desc_'+n;
desc.readOnly=true;
desc.setAttribute('onKeyDown', 'return pasarEnter(this.id,event);');
//desc.onkeypress = function() {return pasarEnter(this.id,event);};
celda.appendChild(desc);
celda = document.createElement('td');
fila.appendChild(celda);
emb=document.createElement('input');
emb.type='text';
emb.name='emb_'+n;
emb.id='emb_'+n;
emb.readOnly=true;
emb.size='6';
emb.maxLength='5';
emb.setAttribute('onKeyDown', 'return pasarEnter(this.id,event);');
celda.appendChild(emb);
celda = document.createElement('td');
fila.appendChild(celda);
caj=document.createElement('input');
caj.type='text';
caj.name='caj_'+n;
caj.id='caj_'+n;
caj.size='4';
caj.maxLength='4';
//caj.onchange = function() {calculo(this.id,actual)};
caj.setAttribute('onKeyDown', 'if(esValido(event)){calculo(this.id,'+actual+')};')
//caj.onkeyup = function() {if(esValido(event)){calculo(this.id,actual)};};
celda.appendChild(caj);
celda = document.createElement('td');
fila.appendChild(celda);
und=document.createElement('input');
und.type='text';
und.name='und_'+n;
und.id='und_'+n;
und.size='5';
und.maxLength='3';
//und.onchange = function() {calculo(this.id,actual)};
und.setAttribute('onKeyDown', 'if(esValido(event)){calculo(this.id,'+actual+')};')
celda.appendChild(und);
celda = document.createElement('td');
fila.appendChild(celda);
vund=document.createElement('input');
vund.type='text';
vund.name='vund_'+n;
vund.id='vund_'+n;
vund.size='7';
vund.readOnly=true;
vund.setAttribute('onKeyDown', 'if(esValido(event)){calculo(this.id,'+actual+')};')
celda.appendChild(vund);
celda = document.createElement('td');
fila.appendChild(celda);
des=document.createElement('input');
des.type='text';
des.name='des_'+n;
des.id='des_'+n;
des.size='4';
des.maxLength='2';
//des.onchange = function() {calculo(this.id,actual)};
des.setAttribute('onKeyDown', 'if(esValido(event)){calculo(this.id,'+actual+')};');
//des.setAttribute('onBlur', 'calculo(this.id,'+actual+');');
//des.onblur= function() {if(window.event){tecla = event.keyCode;}else if(event.which){tecla = event.which;}if(tecla=='13'){calculo(this.id,actual)};};
celda.appendChild(des);
celda = document.createElement('td');
fila.appendChild(celda);
des2=document.createElement('input');
des2.type='text';
des2.name='des2_'+n;
des2.id='des2_'+n;
des2.size='4';
des2.maxlength='2';
//des2.onchange = function() {calculo(this.id,actual)};
des2.setAttribute('onKeyDown', 'if(esValido(event)){calculo(this.id,'+actual+')};')
celda.appendChild(des2);
celda = document.createElement('td');
fila.appendChild(celda);
iva=document.createElement('input');
iva.type='text';
iva.name='iva_'+n;
iva.id='iva_'+n;
iva.size='4';
iva.maxLength='2';
//iva.onchange = function() {calculo(this.id,actual)};
iva.setAttribute('onKeyDown', 'if(esValido(event)){calculo(this.id,'+actual+')};')
celda.appendChild(iva);
celda = document.createElement('td');
fila.appendChild(celda);
total=document.createElement('input');
total.type='text';
total.name='total_'+n;
total.id='total_'+n;
total.readOnly=true;
total.size='11';
total.setAttribute('style', 'text-align: right;');
celda.appendChild(total);
tabla.appendChild(fila);
document.getElementById("cod_"+n).focus();
}
Con ella agrego los campos, pero en firefox es como si no los agregara, ya que al hacer el submit, los valores ingresados en esos campos no son enviados...