I have been trying to get array values to form a table and I am almost there, I just keep running into one issue. My table has 7 columns and 6 rows. I was required to have an array for each of the variables but when I actually create the table 3 of the arrays have to be put together and then each value for each of the three arrays put in the column down. This is what I have accomplished so far for code:
<br />
var colCount = 7;<br />
var rowCount = 7;<br />
<br />
var id = new Array("1022", "1112", "1230", "554", "1355", "1600");<br />
var title = new Array("Prof.", "Prof.", "Prof.", "Prof.", "Asst. Prof.", "Asst. Prof.");<br />
var name = new Array("Catherine Adler", "Michael Li", "Maria Sanchez", "Robert Hope", "Wayne Li", "Kate Howard");<br />
var position = new Array("Department Chair", "Asst. Chair", "TA Supervisor");<br />
var er = new Array(2, 3, 1, 2, 1, 3);<br />
var yoe = new Array(18, 12, 10, 23, 8, 5);<br />
var cs = new Array(85000, 70000, 62000, 55000, 50000, 45000);<br />
<br />
var complicatedName;<br />
for (index = 0; index < rowCount; index++)<br />
{<br />
complicatedName[index] = title[index]+' '+name[index]+' '+position[index];<br />
}<br />
colCount = colCount - 2<br />
<br />
var collist = [id,complicatedName,er,yoe,cs];<br />
<br />
function tableCreate() {<br />
for (rownum = 1; rownum <= rowCount; rownum++) {<br />
document.write("<table><tbody><tr>");<br />
for (colnum = 1; colnum <= colCount; colnum++) { <br />
document.write("<td>" + (collist[(colnum-1)])[(rownum-1)] + "</td>");<br />
}<br />
document.write("</tr></tbody></table>");<br />
}<br />
}<br />
I find that the complicatedName and collist come out to undefined for some strange reason and have no ideas as to why. Index also appears to be undefined.
Any insights would be helpful and if extra clarification is needed please ask.