<html> <head> <!-- Answer2-TCA.html - based on Sam Brodkin's answer 2 1) Modified to emit end-of-table tag *before* prompting to continue. This "flushes the buffer" on the table and synchronizes the input and output. 2) Modified to use a separate window for the output, just in case. 3) Closes output window at end of run to prepare for "reload" of the main window. --> <SCRIPT> <!-- //declare global variables var i = 0; var numCounter = 0; var numCells = 0; //This function wraps numbers passed to it in table html function tablify(i,win) { if (numCells == 0) { //starts cells at 0 win.document.write("<tr>"); //starts the row } numCells++; //increments cells by 1 win.document.write("<td>" + i + "</td>"); //writes the cells if (numCells == 10) { //sets number of cells across to 10 win.document.write("</tr>"); //ends the row numCells = 0; //sets cells back to 0 in the loop } } //--> </SCRIPT> </head> <body> <!-- following code added by server. PLEASE REMOVE --> <!-- preceding code added by server. PLEASE REMOVE --> <SCRIPT> <!-- newwin=window.open("","","width=300,height=300,menubars=yes,scrollbars=yes,resizable=yes") newwin.document.write("Hello"); newwin.document.write("<TABLE BORDER=2>"); //whileloop: //label the while loop "whileloop" whileloop: while (i < 100) { i++; //increment i by 1 numCounter++; //increment counter by 1 tablify(i,newwin); //call Tablify function if (numCounter == 25) { //when the counter reaches 25 newwin.document.writeln("</table><table border=2>"); bResult = confirm("we're at " + i + " continue?"); if (bResult == false) { newwin.document.writeln("</TR>"); break whileloop; } //start new table. this gets it to print each time //otherwise we have to wait till the end to see the numbers print newwin.document.write("<TABLE BORDER=2>"); numCounter = 0; //reset counter. Could have used mod function //instead of this counter //reset counter to 0 } } newwin.document.write("</table>"); newwin.document.close(); //--> </SCRIPT> <BODY></HTML> 1