15.02.2013 Views

JavaScript Examples Bible - UserWorks Technologies

JavaScript Examples Bible - UserWorks Technologies

JavaScript Examples Bible - UserWorks Technologies

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

392<br />

TD.cellIndex<br />

<strong>JavaScript</strong> <strong>Examples</strong> <strong>Bible</strong>: The Essential Companion to <strong>JavaScript</strong> <strong>Bible</strong><br />

Example<br />

Use The Evaluator (Chapter 13 in the <strong>JavaScript</strong> <strong>Bible</strong>) in IE4+ to expand the<br />

height of the second row of the demonstrator table. Enter the following statement<br />

into the top text box:<br />

document.all.myTable.rows[1].height = 300<br />

If you attempt to set the value very low, the rendered height goes no smaller than<br />

the default height.<br />

rowIndex<br />

sectionRowIndex<br />

NN2 NN3 NN4 NN6 IE3/J1 IE3/J2 IE4 IE5 IE5.5<br />

Compatibility ✓ ✓ ✓ ✓<br />

Example<br />

Use The Evaluator (Chapter 13 in the <strong>JavaScript</strong> <strong>Bible</strong>) to explore the rowIndex<br />

and sectionRowIndex property values for the second physical row in the demonstrator<br />

table. Enter each of the following statements into the top text box (W3C<br />

DOM syntax shown here):<br />

document.getElementById(“myTable”).rows[1].rowIndex<br />

document.getElementById(“myTable”).rows[1].sectionRowIndex<br />

The result of the first statement is 1 because the second row is the second row<br />

of the entire table. But the sectionRowIndex property returns 0 because this row<br />

is the first row of the TBODY element in this particular table.<br />

TD and TH Element Objects<br />

Properties<br />

cellIndex<br />

NN2 NN3 NN4 NN6 IE3/J1 IE3/J2 IE4 IE5 IE5.5<br />

Compatibility ✓ ✓ ✓ ✓<br />

Example<br />

You can rewrite the cell addition portion of Listing 27-2 (in Chapter 27 in the<br />

<strong>JavaScript</strong> <strong>Bible</strong>) to utilize the cellIndex property. The process entails modifying<br />

the insertTableRow() function so that it uses a do...while construction to keep<br />

adding cells to match the number of data slots. The function looks like the following<br />

(changes shown in boldface):

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!