3.0.0

Dynamically Adding a row to a table

I am trying to use this 'code' to dynamicall build a table and add rows to it. However nothing is displayed. Could someone tell me what is wrong.

<html>
<head>
<script language = "javascript" type = "text/javascript">
var total_holes = 6;
var playoffObj = getEl('playoff');
var colspan_total = total_holes + 2;

var newT = document.createElement('table');
newT.id = "playoffTBL";
newT.width = 735;
newT.cellSpacing = 0;
newT.cellPadding = 0;

var newTbody = document.createElement('tbody');
newTbody.id = "playoffBody"

var newTR, newTD;

newTR = document.createElement('tr');
newTR.className = "header";

newTD = document.createElement('td');
newTD.colSpan = colspan_total;
newTD.align = "center";
newTD.innerHTML = "Playoff (Sudden Death)";
newTR.appendChild(newTD);

newT.appendChild(newTbody);
playoffObj.appendChild(newT);

document.write(newT );
</script>

</body>
</html>

Still trying to teach myself.

Thanks for your help
Vernon
December 27,
You should consider this:
<html>
<head>

</head>
<body>
    <div id="playoff"></div>
</body>

<script language = "javascript" type = "text/javascript">
var total_holes = 6;
var playoffObj = document.getElementById('playoff');
var colspan_total = total_holes + 2;

var newT = document.createElement('table');
newT.id = "playoffTBL";
newT.width = 735;
newT.cellSpacing = 0;
newT.cellPadding = 0;

var newTbody = document.createElement('tbody');
newTbody.id = "playoffBody"

var newTR, newTD;

newTR = document.createElement('tr');
newTR.className = "header";

newTD = document.createElement('td');
newTD.colSpan = colspan_total;
newTD.align = "center";
newTD.innerHTML = "Playoff (Sudden Death)";
newTR.appendChild(newTD);

newTbody.appendChild(newTR);

newT.appendChild(newTbody);
playoffObj.appendChild(newT);
</script>
</html>

Charboy
February 16,

This topic is archived.

See also:


Back to support forum

Search

Version 2

Looking for AW 2.6 ?
The old site is here.