:: Forum >> Version 2 >>

Dynamically Adding a row to a table

More information on this topic is available in the documentation section: /active.howto.load.xml/.

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
Tuesday, December 27, 2005
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 newTRnewTD;

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
Thursday, February 16, 2006



This topic is archived.

Back to /active.howto.load.xml/

Documentation:

Forum search