I have a simple HTML table with first name, last name as the column headers. I am adding an age column and want to populate the rows with values from an array but am having issues. Here is my code:
Code:
<html>
	<head>
		<title>Untitled Page</title>
	</head>
	<body>
				<h1>The Seinfeld Family</h1>
				<table id="Seinfeld Family" bgcolor=#66ffc border="1" style="width:533px;">
					<tr  bgcolor=#ff0000><th>First Name</th><th>Last Name</th></tr>
					<tr><td>George</td><td>Constanza</td></tr>
					<tr><td>Jerry</td><td>Seinfeld</td></tr>
					<tr><td>Krammer</td><td>Cosmo</td></tr>
					<tr><td>Elaine</td><td>Benice</td></tr>
					<tr><td>Larry</td><td>King</td></tr>
					<tr><td>Bill</td><td>O'Reilly</td></tr>
				</table>
				
				<script type="text/javascript">
				var table=document.getElementById("Seinfeld Family");
				//insert allert statements here
				alert(table.nodeName);
	            alert(table.childNodes[1].nodeName);
	            alert(table.childNodes[1].childNodes[0].nodeName);
	            alert(table.childNodes[1].childNodes[0].childNodes[0].nodeName);
                    alert(table.childNodes[1].childNodes[0].childNodes[0].childNodes[0].nodeName);

				
				
				//code to add a new column to the Seinfeld Family table
				var tableBody=table.getElementsByTagName("TBODY");
				var tableRows=tableBody[0].getElementsByTagName("TR");
				var headerRow=tableRows[0];
				var headerColumns=headerRow.childNodes;
				
				alert("Adding column header...");
				var newColumn=document.createElement('TH');
				var newColumnText=document.createTextNode("Age");
                                newColumn.appendChild(newColumnText);
				headerRow.appendChild(newColumn);
				
				//fill in code to add data in the Age column here
				var ageValues=["36","42","44","56","35","56"];
				
				
        			
    
				//step c)
				
				
				
				//add ID collumn and generate ID values
				//step d)
				alert("Adding column header...");
				var newColumn=document.createElement('TH');
				var newColumnText=document.createTextNode("ID");
                                newColumn.appendChild(newColumnText);
				headerRow.appendChild(newColumn);
				
				</script>
	</body>
</html>
Any help is much appreciated.