I have this code to add a row to a table:
var r=document.crea teElement('tr') ;
var c=document.crea teElement('td') ;
var cn=c.cloneNode( false);
cn.className='t dname'; cn.appendChild( document.create TextNode(p));
var c2=c.cloneNode( false);
var i=document.crea teElement('inpu t');
i.type='text'; i.size=8; i.className='it ext';
var i2=i.cloneNode( true); i.name=p+'pas'; i2.name=p+'fun' ;
c.appendChild(i );
c2.appendChild( i2);
r.appendChild(c n);
r.appendChild(c );
r.appendChild(c 2);
var x=document.getE lementsByTagNam e('table')[0].rows;
x=x[x.length-1]; // the one before the last
x.parentNode.in sertBefore(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.crea teElement('tr') ;
var c=document.crea teElement('td') ;
var cn=c.cloneNode( false);
cn.className='t dname'; cn.appendChild( document.create TextNode(p));
var c2=c.cloneNode( false);
var i=document.crea teElement('inpu t');
i.type='text'; i.size=8; i.className='it ext';
var i2=i.cloneNode( true); i.name=p+'pas'; i2.name=p+'fun' ;
c.appendChild(i );
c2.appendChild( i2);
r.appendChild(c n);
r.appendChild(c );
r.appendChild(c 2);
var x=document.getE lementsByTagNam e('table')[0].rows;
x=x[x.length-1]; // the one before the last
x.parentNode.in sertBefore(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
Comment