I
Ivo
I have this code to add a row to a table:
var r=document.createElement('tr');
var c=document.createElement('td');
var cn=c.cloneNode(false);
cn.className='tdname'; cn.appendChild(document.createTextNode(p));
var c2=c.cloneNode(false);
var i=document.createElement('input');
i.type='text'; i.size=8; i.className='itext';
var i2=i.cloneNode(true); i.name=p+'pas'; i2.name=p+'fun';
c.appendChild(i);
c2.appendChild(i2);
r.appendChild(cn);
r.appendChild(c);
r.appendChild(c2);
var x=document.getElementsByTagName('table')[0].rows;
x=x[x.length-1]; // the one before the last
x.parentNode.insertBefore(r,x);
I 'm sure I 'm missing something obvious, the row is added correctly,
containing the expected cells each with the right input elements, but the
generated input elements don't have names. It is the same with inputs of
type checkbox. The classes are set correctly, but [element].name returns
undefined. Howcome and what can I do about it?
Thanks
Ivo
var r=document.createElement('tr');
var c=document.createElement('td');
var cn=c.cloneNode(false);
cn.className='tdname'; cn.appendChild(document.createTextNode(p));
var c2=c.cloneNode(false);
var i=document.createElement('input');
i.type='text'; i.size=8; i.className='itext';
var i2=i.cloneNode(true); i.name=p+'pas'; i2.name=p+'fun';
c.appendChild(i);
c2.appendChild(i2);
r.appendChild(cn);
r.appendChild(c);
r.appendChild(c2);
var x=document.getElementsByTagName('table')[0].rows;
x=x[x.length-1]; // the one before the last
x.parentNode.insertBefore(r,x);
I 'm sure I 'm missing something obvious, the row is added correctly,
containing the expected cells each with the right input elements, but the
generated input elements don't have names. It is the same with inputs of
type checkbox. The classes are set correctly, but [element].name returns
undefined. Howcome and what can I do about it?
Thanks
Ivo