CassidyHunt
IS-IT--Management
I am trying to build a custom user control for one of my web applications and I am testing the javascript piece. I get TableRow undefined and I do not know why.
Here is the code:
Does anyone see why I would receieve that for this line:
Thanks for the help
Cassidy
Here is the code:
Code:
<html xmlns="[URL unfurl="true"]http://www.w3.org/1999/xhtml"[/URL] >
<head runat="server">
<title>Untitled Page</title>
<script type="text/javascript">
// Table Row -- Collection of table cells matching columns
function TableRow(index) {
this.index = index;
this.Columns = [];
};
TableRow.prototype.addColumn =
function(index,name, value) {
if(!index) { index = this.Columns.Length + 1; }
this.Columns[index] = {
ColumnName : name,
ColumnValue : value
};
};
// Table object must be used in conjunction with row object
function Table(objName) {
this.config = {
cssClass : 'treetable',
cellSpacing : 0,
cellPadding : 0,
border : 0,
font-family : 'Arial',
font-size : '10pt',
font-weight: 'normal',
width: '100%'
};
this.obj = objName;
this.Rows = [];
};
Table.prototype.addRow =
function(index, row) {
if(!index) { index = this.Rows.Length + 1; }
this.Rows[index] = row;
return false;
};
Table.prototype.RenderHTML =
function(parentElementId) {
var parent = document.getElementById(parentElementId);
var table = new document.createElement("Table");
for(var i=0; i < this.Rows.Length; i++) {
var tr = new document.createElement("tr");
for(var d=0; d < this.Rows[i].Columns.Length; d++) {
var td = new document.createElement("td");
var text = new document.createTextNode(this.Rows[i].Columns[d].ColumnValue);
td.appendChild(text);
tr.appendChild(td);
}
table.appendChild(tr);
}
parent.appendChild(table);
};
</script>
<style type="text/css">
.branch {
display: block;
margin-left: 16px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<script type="text/javascript" >
var a_row = new TableRow(0);
a_row.addColumn(0,'Test 1', 1);
a_row.addColumn(1,'Test 2', 2);
a_row.addColumn(2,'Test 3', 3);
var b_row = new TableRow(1);
b_row.addColumn(3,'Test 1', 4);
b_row.addColumn(4,'Test 2', 5);
b_row.addColumn(5,'Test 3', 6);
var a_Table = new Table('a_Table');
a_Table.addRow(0,a_row);
a_Table.addRow(1,b_row);
a_Table.RenderHTML('me');
</script>
<div id="me">
</div>
</div>
</form>
</body>
</html>
Does anyone see why I would receieve that for this line:
Code:
var a_row = new TableRow(0);
Thanks for the help
Cassidy