The multiplication table just needs to be going up to 10, and it should involve CSS. Can someone post some links or hints so that I can get started on this assignment for Lab CS120 Lab 7b. Thank you.
You can try following code: <html> <body> <div id="cover"> </div> <script> function addTable(container, level) { Â if (level > 10) return; Â var tb = document.createElement('table'); Â var tr = document.createElement('tr'); Â var td = document.createElement('td'); Â container.appendChild(tb); tb.appendChild(tr); Â tr.appendChild(td); Â td.innerHTML = 'level ' + level; Â td.style.border = 'solid 1px red'; Â tb.style.width = '100%'; Â addTable(td, level + 1); } addTable(document.getElementById('cover'), 1); </script> </body> </html> Code (markup): Â
I think this is what you are looking for. Just change the renderTable(10) to renderTable(someOtherNumber) to change how big you want the table to be. <html> <head> <style type="text/css"> table, td { border: 1px solid #999999; } </style> <script type="text/javascript"> function renderTable(highestDegree) { document.write("<table cellspacing='0' cellpadding='5'><tr>"); var i = 1; for (i = 1; i <= highestDegree; i++) { var j = 1; for (j = 1; j <= highestDegree; j++) { document.write("<td>"+ (i * j) +"</td>"); } document.write("</tr><tr>"); } document.write("</tr></table>"); } </script> </head> <body> <script type="text/javascript">renderTable(10);</script> </body> </html> HTML: