Here's my code:
var arrayOne = new Array(11); for (var i = 0; i <= 10; i++) { arrayOne[i] = i; } var newWindow; function openWindow() { if (!(newWindow)) { newWindow = window.open(); } } function closeWindow() { newwindow.document.close(); } /* make a addition table... */ function additionTable() { openWindow(); newwindow.document.write("<table border=1 cellspacing=1 cellpadding=5>"); for (var i = 0; i < 11; i++) { newwindow.document.write("<tr>"); for (var j = 0; j < 11; j++) { newwindow.document.write("<td>" + (i + j) + "</td>"); } newwindow.document.write("</tr>"); } closeWindow(); } /* make a multiplication table... */ function multiplicationTable() { openWindow(); newwindow.document.write("<table border=1 cellspacing=1 cellpadding=5>"); for (var i = 0; i < 11; i++) { newwindow.document.write("<tr>"); for (var j = 0; j < 11; j++) { newwindow.document.write("<td>" + i * j + "</td>"); } newwindow.document.write("</tr>"); } closeWindow(); }
My results are a table similar to this:
000 000 000 000 000 000 000 000 000 000 000 000 001 002 003 004 005 006 007 008 009 010 000 002 004 006 008 010 012 014 016 018 020 000 003 006 009 012 015 018 021 024 027 030 000 004 008 012 016 020 024 028 032 036 040 000 005 010 015 020 025 030 035 040 045 050 000 006 012 018 024 030 036 042 048 054 060 000 007 014 021 028 035 042 049 056 063 070 000 008 016 024 032 040 048 056 064 072 080 000 009 018 027 036 045 054 063 072 081 090 000 010 020 030 040 050 060 070 080 090 100
I've tried doing this:
for (var i = 0; i < 11; i++) { newwindow.document.write("<tr>"); /* doing this gets me the first colum but not the first row correct */ newwindow.document.write("<td>" + i + "</td>"); /* to make up for adding an extra column *basicly*, i start j at 1 instead of 0 */ for (var j = 1; j < 11; j++) { newwindow.document.write("<td>" + (i + j) + "</td>"); } newwindow.document.write("</tr>"); }
The other functions are for creating a new window and outputting the table. It believe that part works ok, my main concern is multiplication table output.
Thanks in advance,
Josh