I'm trying to create a table of all the zodiac symbols with their years underneath (12 columns, n rows, dates range from 1912 to 2013) using multidimensional arrays.
I have my code below and that's where I'm completely stuck.
My code:
<script>
// declaring a 2D array
var signs = new Array(12);
for (var ndx = 0; ndx < 12; ndx++) {
signs[ndx] = new Array(2);
}
// The names first
signs[0][0] = "Rat";
signs[1][0] = "Ox";
signs[2][0] = "Tiger";
signs[3][0] = "Rabbit";
signs[4][0] = "Dragon";
signs[5][0] = "Snake";
signs[6][0] = "Horse";
signs[7][0] = "Goat";
signs[8][0] = "Monkey";
signs[9][0] = "Rooster";
signs[10][0] = "Dog";
signs[11][0] = "Pig";
// Next the image file names
signs[0][1] = "rat.gif";
signs[1][1] = "ox.gif";
signs[2][1] = "tgr.gif";
signs[3][1] = "rbt.png";
signs[4][1] = "drgn.png";
signs[5][1] = "snk.png";
signs[6][1] = "hrs.gif";
signs[7][1] = "gt.gif";
signs[8][1] = "mnky.png";
signs[9][1] = "rstr.gif";
signs[10][1] = "dog.gif";
signs[11][1] = "pig.gif";
document.write("<h2>");
document.write("</h2>");
document.writeln("<table border= '0' width = '100%'>");
document.writeln("<tr>");
for (var i = 0; i < SignNames.length; i++) {
document.writeln("<td>");
document.writeln(SignNames[i] + "<br />");
document.writeln("<img src='Images/" + SignImages[i] + "'/>");
document.writeln("</td>");
}
document.writeln("</tr>");
document.writeln("<tr>");
for (var i = 1912; i <= new Date().getFullYear(); i++) {
document.writeln("<td>" + i + "</td>");
tableCols++;
if (tableCols == 12) {
tableCols = 0;
document.writeln("</tr>");
}
}
document.writeln("</table>");
</script>