I have created a table using a for loop in my code and have various variables in multiple arrays. I want to be able to put the values from the array individually into each table cell going down in a column. For code I have this:
function tableCreate() {
for (rownum = 1; rownum <= 7; rownum++) {
document.write("<tr>");
for (colnum = 1; colnum <= 7; colnum++) {
if (rownum == 1 + colnum == 1) {
document.write("<td>" + id[0] + "</td>");
}
}
document.write("</tr>");
}
}
var id = new Array("1022", "1112", "1230", "554", "1355", "1600");
var title = new Array("Prof.", "Prof.", "Prof.", "Prof.", "Asst. Prof.", "Asst. Prof.");
var name = new Array("Catherine Adler", "Michael Li", "Maria Sanchez", "Robert Hope", "Wayne Li", "Kate Howard");
var position = new Array("Department Chair", "Asst. Chair", "TA Supervisor");
var er = new Array(2, 3, 1, 2, 1, 3);
var yoe = new Array(18, 12, 10, 23, 8, 5);
var cs = new Array(85000, 70000, 62000, 55000, 50000, 45000);
The above code is all part of an external JavaScript document. I tryed using if statements to produce what I wanted but that failed. Now I’m lost and some help would be appreciated. To reitterate, I want to get say this array: var id = new Array(“1022”, “1112”, “1230”, “554”, “1355”, “1600”);
into a table column and have each variable in that array take a cell in that column.
Not so clear but I think what you want is this:
I expect this is really what you want: