Dynamic table, setting v-align of a new cell

R

Rich Morey

Hello,

I am working on something that only needs to work in IE, and I've got
this code:

var aRows=oTable.rows;
var oCell1_1=aRows(0).insertCell();
oCell1_1.innerHTML= 'new cell'

Which inserts a row in my table and I can populate the cell with the
text using the innerHTML property. No problem.

My question is, how do I set the VALIGN of this new cell?

I have tried this..

oCell1_1.valign='top'

and that does not generate a JavaScript error but it doesn't
vertically align the text in the cell either.

Other attempts generate javascript errors..

Can someone please help!

Thanks,

Rich
 
L

Lasse Reichstein Nielsen

DU said:
var oCell1_1=aRows[0].insertCell(i); ....
If you're going to insert only a text node, then it's preferable to use
oCell1_1.firstChild.nodeValue= 'new cell';

rather than use innerHTML

In a brand new td node, there is no firstChild. In this case, you should
rather do a
oCell1_1.appendChild(document.createTextNode('new cell'));
to create the text node.
This might depend on the browser and browser version.

The correct syntax is with vAlign, otherwise a script error should
have been generated and reported.

Not necessarily. The DOM node is a host object, so behavior doesn't
have to follow Javascript objects, but I haven't seen a DOM
implementation yet that didn't allow you to create any property.
It's not an error. It just won't do anything.

/L
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,821
Latest member
AleidaSchi

Latest Threads

Top