<HTML> <!-- ARCHIVE by FORTUNECITY.ws --> <HEAD> <TITLE>Assignment-2 </TITLE> <SCRIPT LANGUAGE ="JavaScript"> <!-- //declare the variables in this program. var i = 1; var answer; var response; var statement; var bResult; //get a number from the body of the page, and build a table around it. function makeTable(i) { document.writeln("<TABLE BORDER = 1 CELLPADDING = 5>"); document.writeln("<TR>" + "<TD BGCOLOR=YELLOW>" + i + "</TD>"+"</TR>"); document.writeln("</TABLE>"); } //--> </SCRIPT> </HEAD> <BODY BGCOLOR=BLACK TEXT=BLUE><script> (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,'script','//www.google-analytics.com/analytics.js','ga'); ga('create', 'UA-47423994-1', 'fortunecity.ws'); ga('send', 'pageview'); </script> <center> <br> <div> <script language="javascript" type="text/javascript" src="http://ad.broadcaststation.net/ads/show_ad.php?width=728&height=90"></script> </div> </center> <center> <br> <div style="height:5px"></div> </center> <SCRIPT LANGUAGE = "JavaScript"> <!-- //Center all the content on the web page. document.writeln("<CENTER>"); //asks the user for a number. answer=prompt("Enter a number to indicate how many number to print", "1"); //if the user clicks Cancel, program alerts the user, and stops. if(answer==null) { alert("You've just cancelled the program!!! Bye."); } //if the user input a number, the program continues. if(answer!=null) {//if the user input a number larger than 0, the program ask the user to //confirm it. if(answer>0) {//inform the user what number the user has just input. response=confirm("You've entered " + answer + "."); } //if no number or an invalid number is entered, the program alert //the user. else { alert("Invalid number, Please restart the program.") } //if the user entered a good number, and clicks OK on the confirm box, the //program will get executed. if(response==true) { outerLoop: while(i<=answer)//the following statements get executed while i is smaller { //than or equal to the number input by the user. //the following two statements ask the user if the user wants //the program continues to work. statement="Want the program keep working? " + " Now at #"+(i-1); bResult = confirm(statement); //if the user clicks Cancel, the program will print a message on the //page, and stop. if(bResult == false) { document.writeln("<BR>") document.writeln("The program has stopped"); break outerLoop; } //if the user clicks OK, the program will continue. else { //the program calls the makeTable function. makeTable(i); }; i++; } document.writeln("</CENTER>"); } //if the user clicks Cancel, the program will alert the user and stop. else { if(answer>0) { alert("You've just cancelled the program!!! Bye."); } } } //--> </SCRIPT> </BODY> <!-- ARCHIVE by FORTUNECITY.ws --> <center> <div> <br> <script language="javascript" type="text/javascript" src="http://ad.broadcaststation.net/ads/show_ad.php?width=300&height=250&cache=0"></script> <script language="javascript" type="text/javascript" src="http://ad.broadcaststation.net/ads/show_ad.php?width=300&height=250"></script> </div> <br> <br> </center> </HTML>