lyllo
05-20-2009, 11:22 PM
first of all, HELLO to everyone.
I am new in this forumso let me greet everyone!
now, after presentation is complete let me expose my problem:
i have a script which dynamically has to add rows to a table. it has to do that in a "CONDITIONAL" way, i mean, that it is triggered by a condition: when all the already present rows have been all filled, it shoudl create a new set of 3 rows.
it should do the check and the eventual dynamic creation when the user hits ENTER.
in firefox everything works fine, in IE not.
the weird thing is that in IE the first 2 rows are inserted correctly, successive ones NO MORE.
here it is the part of the code which basically checks the ID of the previous input field. it evaluates the number contained in the ID and if it is >= 10 it creates the rows.
can't understand the reason why once created the first set of 2 rows, arriving to row "12" it stops working.
function evalHP(e, val, id){
var characterCode
if(e && e.which){
e = e
characterCode = e.which
}
else{
e = window.event
characterCode = e.keyCode //IE
}
if(characterCode == 13){ //ENTER
var el = document.getElementById(id);
el.style.fontWeight = 'bold';
el.style.backgroundColor = 'transparent';
el.style.textAlign = 'center';
el.style.border = '0';
el.style.color = '#FF0000';
r = id.split('_');
let = r[1];
n_i = r[3];
if(n_i >= 10){ //IF YOU HAVE REACHED ROW 10 CREATE 2 MORE NEW ROWS
for(i=1;i<3; i++){
var colSX = document.createElement("TD");
nid= parseInt(r[3])+i;
colSX.setAttribute('id',"td_"+let+"_"+r[2]+"_"+nid);
colSX.style.fontSize ='8pt';
var colDX = document.createElement("TD");
var inp = document.createElement("INPUT");
inp.style.border = '0px';
inp.setAttribute('size', 8);
id_inp = 'inp_'+let+"_"+r[2]+"_"+nid;
inp.setAttribute('id',id_inp);
if(bro == 'moz'){
inp.setAttribute('class','piccolo');
inp.setAttribute('onkeypress', 'evalHP(event, this.value, this.id)');
}
if(bro == 'ie'){
inp.setAttribute('className','piccolo');
inp.onkeydown = 'evalHP(event, this.value, this.id)';
}
colDX.appendChild(inp);
var riga = document.createElement("TR");
riga.appendChild(colSX);
riga.appendChild(colDX);
document.getElementById('tbd_'+let).appendChild(riga);
document.getElementById('tbl_'+let).appendChild(document.getElementById('tbd_'+let));
}
}
nprev = parseInt(r[3])-1;
nnext = parseInt(r[3])+1;
nNnext = parseInt(r[3])+2;
id_next = 'inp_'+let+"_"+r[2]+"_"+nnext;
id_Nnext = 'inp_'+let+"_"+r[2]+"_"+nNnext;
id_nprev = 'inp_'+let+"_"+r[2]+"_"+nprev;
id_td = 'td_'+let+"_"+r[2]+"_"+n_i;
if(document.getElementById(id_nprev))num = document.getElementById(id_nprev).value;
else num = document.getElementById("MAX_"+id_nprev).value;
if(!document.getElementById("ck_pf"+let).checked){
document.getElementById(id_next).value = num - val;
document.getElementById("evalHP_"+let).value = num - val;
if(bro == 'moz') document.getElementById(id_td).innerHTML = "<font style='font-size: 8pt;'>Danni</font>";
if(bro == 'ie'){
var otxt = document.createTextNode("Danni");
document.getElementById(id_td).appendChild(otxt);
}
}
else{
document.getElementById(id_next).value = parseInt(num) + parseInt(val);
document.getElementById(id).style.color = '#339966';
document.getElementById("evalHP_"+let).value = parseInt(num) + parseInt(val);
if(bro == 'moz') document.getElementById(id_td).innerHTML = "<font style='font-size: 8pt;' />Cura</font>";
if(bro == 'ie'){
var otxt = document.createTextNode("Cura");
document.getElementById(id_td).appendChild(otxt);
}
document.getElementById("ck_pf"+let).checked = false;
}
document.getElementById(id_next).style.textAlign = 'center';
document.getElementById(id_next).style.border = '0';
document.getElementById(id_Nnext).focus();
return false
}
else{
return true
}
...
once created the set to row 12, it stops working and the script does not detect even the ENTER press anymore.
any hint?
thank you.
I am new in this forumso let me greet everyone!
now, after presentation is complete let me expose my problem:
i have a script which dynamically has to add rows to a table. it has to do that in a "CONDITIONAL" way, i mean, that it is triggered by a condition: when all the already present rows have been all filled, it shoudl create a new set of 3 rows.
it should do the check and the eventual dynamic creation when the user hits ENTER.
in firefox everything works fine, in IE not.
the weird thing is that in IE the first 2 rows are inserted correctly, successive ones NO MORE.
here it is the part of the code which basically checks the ID of the previous input field. it evaluates the number contained in the ID and if it is >= 10 it creates the rows.
can't understand the reason why once created the first set of 2 rows, arriving to row "12" it stops working.
function evalHP(e, val, id){
var characterCode
if(e && e.which){
e = e
characterCode = e.which
}
else{
e = window.event
characterCode = e.keyCode //IE
}
if(characterCode == 13){ //ENTER
var el = document.getElementById(id);
el.style.fontWeight = 'bold';
el.style.backgroundColor = 'transparent';
el.style.textAlign = 'center';
el.style.border = '0';
el.style.color = '#FF0000';
r = id.split('_');
let = r[1];
n_i = r[3];
if(n_i >= 10){ //IF YOU HAVE REACHED ROW 10 CREATE 2 MORE NEW ROWS
for(i=1;i<3; i++){
var colSX = document.createElement("TD");
nid= parseInt(r[3])+i;
colSX.setAttribute('id',"td_"+let+"_"+r[2]+"_"+nid);
colSX.style.fontSize ='8pt';
var colDX = document.createElement("TD");
var inp = document.createElement("INPUT");
inp.style.border = '0px';
inp.setAttribute('size', 8);
id_inp = 'inp_'+let+"_"+r[2]+"_"+nid;
inp.setAttribute('id',id_inp);
if(bro == 'moz'){
inp.setAttribute('class','piccolo');
inp.setAttribute('onkeypress', 'evalHP(event, this.value, this.id)');
}
if(bro == 'ie'){
inp.setAttribute('className','piccolo');
inp.onkeydown = 'evalHP(event, this.value, this.id)';
}
colDX.appendChild(inp);
var riga = document.createElement("TR");
riga.appendChild(colSX);
riga.appendChild(colDX);
document.getElementById('tbd_'+let).appendChild(riga);
document.getElementById('tbl_'+let).appendChild(document.getElementById('tbd_'+let));
}
}
nprev = parseInt(r[3])-1;
nnext = parseInt(r[3])+1;
nNnext = parseInt(r[3])+2;
id_next = 'inp_'+let+"_"+r[2]+"_"+nnext;
id_Nnext = 'inp_'+let+"_"+r[2]+"_"+nNnext;
id_nprev = 'inp_'+let+"_"+r[2]+"_"+nprev;
id_td = 'td_'+let+"_"+r[2]+"_"+n_i;
if(document.getElementById(id_nprev))num = document.getElementById(id_nprev).value;
else num = document.getElementById("MAX_"+id_nprev).value;
if(!document.getElementById("ck_pf"+let).checked){
document.getElementById(id_next).value = num - val;
document.getElementById("evalHP_"+let).value = num - val;
if(bro == 'moz') document.getElementById(id_td).innerHTML = "<font style='font-size: 8pt;'>Danni</font>";
if(bro == 'ie'){
var otxt = document.createTextNode("Danni");
document.getElementById(id_td).appendChild(otxt);
}
}
else{
document.getElementById(id_next).value = parseInt(num) + parseInt(val);
document.getElementById(id).style.color = '#339966';
document.getElementById("evalHP_"+let).value = parseInt(num) + parseInt(val);
if(bro == 'moz') document.getElementById(id_td).innerHTML = "<font style='font-size: 8pt;' />Cura</font>";
if(bro == 'ie'){
var otxt = document.createTextNode("Cura");
document.getElementById(id_td).appendChild(otxt);
}
document.getElementById("ck_pf"+let).checked = false;
}
document.getElementById(id_next).style.textAlign = 'center';
document.getElementById(id_next).style.border = '0';
document.getElementById(id_Nnext).focus();
return false
}
else{
return true
}
...
once created the set to row 12, it stops working and the script does not detect even the ENTER press anymore.
any hint?
thank you.