<SCRIPT LANGUAGE="JScript">
// Declare variables and create the header, footer, and caption.
var oTHead = oTable.createTHead();
var oTFoot = oTable.createTFoot();
var oCaption = oTable.createCaption();
var oRow, oCell;
var i, j;
// Declare stock data that would normally be retrieved from a stock Web site.
var heading = new Array;
// Insert a row into the header.
oRow = oTHead.insertRow();
oTHead.bgColor = "lightskyblue";
// Insert cells into the header row.
for (i=0; i<4; i++)
{
oCell = oRow.insertCell();
oCell.align = "center";
oCell.style.fontWeight = "bold";
oCell.innerText = heading[i];
}
// Insert rows and cells into the first body.
for (i=0; i<2; i++)
{
oRow = oTBody0.insertRow();
for (j=0; j<4; j++)
{
oCell = oRow.insertCell();
oCell.innerText = stock[i + "," + j];
}
}
// Set the background color of the first body.
oTBody0.bgColor = "lemonchiffon";
// Insert rows and cells into the second body.
for (i=2; i<4; i++)
{
oRow = oTBody1.insertRow();
for (j=0; j<4; j++)
{
oCell = oRow.insertCell();
oCell.innerText = stock[i + "," + j];
}
}
// Set the background color of the second body.
oTBody1.bgColor = "goldenrod";
// Insert rows and cells into the footer row.
oRow = oTFoot.insertRow();
oCell = oRow.insertCell();
oCell.innerText = "Quotes are for example only.";
oCell.colSpan = "4";
oCell.bgColor = "lightskyblue";
// Set the innerText of the caption and position it at the bottom of the table.
oCaption.innerText = "Created using Table Object Model."
oCaption.style.fontSize = "10";
oCaption.align = "bottom";
</SCRIPT>
<!-- Placeholder for the table -->
<DIV ID="oTableContainer"></DIV>
<SCRIPT LANGUAGE="JScript">
// Declare variables and create the header, footer, and caption.
var oTable = document.createElement("TABLE");
var oTHead = document.createElement("THEAD");
var oTBody0 = document.createElement("TBODY");
var oTBody1 = document.createElement("TBODY");
var oTFoot = document.createElement("TFOOT");
var oCaption = document.createElement("CAPTION");
var oRow, oCell;
var i, j;
// Declare stock data that would normally be imported from a stock Web site.
var heading = new Array;
// Insert the created elements into oTable.
oTable.appendChild(oTHead);
oTable.appendChild(oTBody0);
oTable.appendChild(oTBody1);
oTable.appendChild(oTFoot);
oTable.appendChild(oCaption);
// Set the table's border width and colors.
oTable.border=1;
oTable.bgColor="lightslategray";
// Insert a row into the header and set its background color.
oRow = document.createElement("TR");
oTHead.appendChild(oRow);
oTHead.bgColor = "lightskyblue";
// Create and insert cells into the header row.
for (i=0; i<4; i++)
{
oCell = document.createElement("TH");
oCell.innerText = heading[i];
oRow.appendChild(oCell);
}
// Create and insert rows and cells into the first body.
for (i=0; i<2; i++)
{
oRow = document.createElement("TR");
oTBody0.appendChild(oRow);
// Set the background color of the second body.
oTBody1.bgColor = "goldenrod";
// Create and insert rows and cells into the footer row.
oRow = document.createElement("TR");
oTFoot.appendChild(oRow);
oCell = document.createElement("TD");
oRow.appendChild(oCell);
oCell.innerText = "Quotes are for example only.";
oCell.colSpan = "4";
oCell.bgColor = "lightskyblue";
// Set the innerText of the caption and position it at the bottom of the table.
oCaption.innerText = "Created using Document Object Model."
oCaption.style.fontSize = "10";
oCaption.align = "bottom";
// Insert the table into the document tree.
oTableContainer.appendChild(oTable);