master
Caleb Fontenot 2023-03-30 13:50:50 +07:00
parent e6549f9343
commit bf8d402aa7
72 changed files with 1665 additions and 0 deletions

1
.gitignore vendored

@ -26,3 +26,4 @@
>>>>>>> Stashed changes
/Assignments/JavaScript/lab15js_CalebFontenot/nbproject/private/
/Assignments/JavaScript/MP11_CalebFontenot/nbproject/private/
/Assignments/JavaScript/lab16js_CalebFontenot/nbproject/private/

@ -0,0 +1,3 @@
{
"directory": "public_html/bower_components"
}

@ -0,0 +1,9 @@
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/ClientSide/Gruntfile.js to edit this template
*/
module.exports = function (grunt) {
// Project configuration.
grunt.initConfig({
});
};

@ -0,0 +1,13 @@
{
"name": "lab16js_CalebFontenot",
"version": "1.0.0",
"main": "path/to/main.css",
"ignore": [
".jshintrc",
"**/*.txt"
],
"dependencies": {
},
"devDependencies": {
}
}

@ -0,0 +1,10 @@
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/ClientSide/gulpfile.js to edit this template
*/
var gulp = require('gulp');
gulp.task('default', function () {
// place code for your default task here
});

@ -0,0 +1,5 @@
file.reference.lab16js_CalebFontenot-public_html=public_html
file.reference.lab16js_CalebFontenot-test=test
files.encoding=UTF-8
site.root.folder=${file.reference.lab16js_CalebFontenot-public_html}
test.folder=${file.reference.lab16js_CalebFontenot-test}

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://www.netbeans.org/ns/project/1">
<type>org.netbeans.modules.web.clientproject</type>
<configuration>
<data xmlns="http://www.netbeans.org/ns/clientside-project/1">
<name>lab16js_CalebFontenot</name>
</data>
</configuration>
</project>

@ -0,0 +1,8 @@
{
"name": "lab16js_CalebFontenot",
"version": "1.0.0",
"keywords": ["util", "functional", "server", "client", "browser"],
"author": "caleb",
"contributors": [],
"dependencies": {}
}

@ -0,0 +1,62 @@
<!DOCTYPE html>
<!--
Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
Click nbfs://nbhost/SystemFileSystem/Templates/Other/html.html to edit this template
-->
<html>
<head>
<title>Point Finder</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script>
// Change the dialog labels if computation changes
function onComputationSelect(computation) {
alert("Selected " + computation);
if (computation === "area") {
document.getElementById('input1Text').innerHTML = "Enter the base: ";
document.getElementById('input2Text').innerHTML = "Enter the height: ";
} else if (computation === "pointDistance") {
document.getElementById('output').innerHTML;
}
}
function onClick() {
// Determine what the user wants us to do.
if (selectComputation.value === "area") {
getArea();
} else if (selectComputation.value === "pointDistance") {
getPointDistance();
}
}
function getInput() {
var input1Val = parseFloat(input1.value);
var input2Val = parseFloat(input2.value);
return [input1Val, input2Val];
}
function getArea() {
var [baseVal, heightVal] = getInput();
var area = (.5 * baseVal) * heightVal;
document.getElementById('output').innerHTML = "The area of " + baseVal + " and " + heightVal + " is " + area;
}
function getPointDistance() {
var [baseVal, heightVal] = getInput();
}
function calculatePower() {
alert("Not implemented!");
}
</script>
</head>
<body>
<label><label id="input1Text">Select a computation type to continue.</label><input type="text" id="input1" name="input1"></label><br>
<label><label id="input2Text">Select a computation type to continue.</label><input type="text" id="input2" name="input2"></label><br>
<label for="selectComputation">What do you want to do?</label>
<select name="selectComputation" id="selectComputation"><br>
<option value="" selected>-- Select computation type --</option>
<option onclick="onComputationSelect(this.value);" value="area">Get Area</option>
<option onclick="onComputationSelect(this.value);" value="pointDistance">Get Point Distance</option>
</select>
<br>
<label id="output"></label><br>
<input type="button" value="Compute!" onclick="onClick()">
</body>
</html>

Binary file not shown.

@ -0,0 +1,146 @@
body {
background-color: #FFFFFF;
background-image: url(background.gif);
color: #0000FF;
font-family: Geneva, Arial, Helvetica, sans-serif;
font-size: 14px;
}
#container { margin-left: auto;
margin-right: auto;
width:85%;
min-width:700px;
}
#logo {
text-align:center;
margin: 0;
font-family: Verdana, Arial, Helvetica, sans-serif;
padding-top: 30px;
padding-bottom: 20px;
}
#nav {
float: left;
width: 200px;
padding-top: 10px;
text-align:left;
color: #FF0000;
font-size: 14px;
}
#nav a {
text-decoration:none;
margin: 15px;
display: block;
color: #FF0000;
font-size: 14px;
font-weight: bold;
}
#content {
margin-left: 150px;
padding: 30px;
overflow:auto;
border: medium groove #0000FF;
line-height: 135%;
}
.floatright {padding-left:20px;
float:right;
}
.floatleft {
float:left;
padding: 2px 30px 20px;
}
#footer {
font-size: 16px;
font-style: normal;
text-align: justify;
border-top: thin none;
padding-top: 20px;
padding-bottom: 20px;
color: #FF0000;
font-family: Georgia, "Times New Roman", Times, serif;
font-weight: bold;
}
h2 { text-transform: uppercase;
color: #0000FF;
font-size: 36px;
border-bottom: 1px none;
margin-right: 20px;
}
h3 {
color: #0000FF;
font-size: 1em;
border-bottom: thin none;
margin-right: auto;
text-align: left;
padding-top: 20px;
padding-right: 150px;
padding-bottom: 20px;
padding-left: 150px;
line-height: 130%;
border-top-style: none;
border-right-style: none;
border-left-style: none;
}
.details { padding-left:20%;
padding-right:20%;
}
img {border:0 none; }
.content {
margin: 20px;
padding: 20px;
height: 3700px;
width: 500px;
}
a {
color: #FF0000;
text-decoration: none;
margin: 15px;
color: #FF0000;
font-size: 14px;
font-weight: bold;
}
a:hover {
color: #FFFF00;
background-color: #0000FF;
}
h4 {
line-height: 150%;
margin-right: 20%;
margin-left: 15%;
text-align: center;
}
h1 {
font-family: Geneva, Arial, Helvetica, sans-serif;
font-size: 36pt;
text-align: center;
margin-right: 15%;
margin-left: 20%;
}
p {
font-family: Georgia, "Times New Roman", Times, serif;
font-size: 16px;
line-height: 130%;
font-weight: bold;
color: #0000FF;
}
.flt_img {
float: none;
padding-top: 3px;
padding-right: 20px;
padding-bottom: 3px;
padding-left: 20px;
}
specialh4 {
line-height: 150%;
margin-right: 20%;
margin-left: 15%;
text-align: center;
}

@ -0,0 +1,23 @@
<html>
<head>
<title>Example 7.1</title>
<script>
function quotient(x,y)
{
illegal = "Illegal division operation";
if (y != 0)
return x/y;
else
return illegal;
}
function clickIt()
{
document.write(quotient(60, 5));
}
</script>
</head>
<body>
<input type ="button" onclick="clickIt()" value = "How much is 60 divided by 5?"></button>
</body>
</html>

@ -0,0 +1,29 @@
<html>
<head>
<title>Example 7.10</title>
<script>
function getValue()
{
var numMice = 12;
document.getElementById('first').innerHTML = (numMice);
numMice = changeValue(numMice);
document.getElementById('third').innerHTML = (numMice);
}
function changeValue(x)
{
var x = 5;
document.getElementById('second').innerHTML = (x);
return x;
}
</script>
</head>
<body><table align="center" width = "70%"><tr><td><br />
<input type ="button" onclick="getValue()" value = "Can you change the number? Try it"><br />
<h3>The value of numMice is: <span id = "first">&nbsp;</span></h3>
<h3>The value of x, in the changeValue() function is: <span id = "second">&nbsp;</span></h3>
<h3>The value of numMice after calling the changeValue() function is: <span id = "third">&nbsp;</span></h3>
</td></tr></table>
</body>
</html>

@ -0,0 +1,49 @@
<html>
<head>
<title>Example 7.11</title>
<script>
function getInfo()
{
var name = prompt("What's your name?");
var email = prompt("What is your email address?");
email = checkEmail(email);
document.getElementById('first').innerHTML = name;
document.getElementById('second').innerHTML = email;
}
function checkEmail(address)
{
flag = true; var atSign = "@"; var address; var okSign = true;
while (flag)
{
var numChars = address.length;
for( j = 1; j < (numChars -5); j++)
{
if (address.charAt(j) == atSign)
okSign = false;
}
if ((address.charAt(numChars - 4) != ".") || (okSign == true))
{
alert("Not a valid email address");
address = prompt('Enter a valid email address or enter "quit" to exit the program');
if (address == "quit")
{
address = "unavailable";
flag = false;
}
}
else
flag = false;
}
return address;
}
</script>
</head>
<body><table align="center" width = "70%"><tr><td><br />
<input type ="button" onclick="getInfo()" value = "Enter your information"><br />
<h3>Your name is: <span id = "first">&nbsp;</span></h3>
<h3>Your email address is: <span id = "second">&nbsp;</span></h3>
</td></tr></table>
</body>
</html>

@ -0,0 +1,27 @@
<html>
<head>
<title>Example 7.12</title>
<script>
function begin()
{
var one = 0; var two = 1; var three = "_"; var four = NaN;
var bool1 = new Boolean(one);
var bool2 = new Boolean(two);
var bool3 = new Boolean(three);
var bool4 = new Boolean(four);
document.getElementById('1').innerHTML = (one + " results in Boolean " + bool1);
document.getElementById('2').innerHTML = (two + " results in Boolean " + bool2);
document.getElementById('3').innerHTML = (three + " results in Boolean " + bool3);
document.getElementById('4').innerHTML = (four + " results in Boolean " + bool4);
}
</script>
</head>
<body><table align="center" width = "70%"><tr><td><br />
<input type ="button" onclick="begin()" value = "Check Boolean values"><br />
<h3><span id = "1">&nbsp;</span></h3>
<h3><span id = "2">&nbsp;</span></h3>
<h3><span id = "3">&nbsp;</span></h3>
<h3><span id = "4">&nbsp;</span></h3>
</td></tr></table>
</body>
</html>

@ -0,0 +1,22 @@
<html>
<head>
<title>Example 7.13</title>
<script>
function begin()
{
var now = new Date(); var before = new Date(); var later = new Date();
before.setFullYear(1812, 2, 3);
later.setFullYear(2095,6,15);
document.getElementById('now').innerHTML = ("Today's date: " + now);
document.getElementById('before').innerHTML = ("In the past it was: " + before);
document.getElementById('later').innerHTML = ("One day it will be: " + later);
}
</script>
</head>
<body><table align="center" width = "70%"><tr><td><br />
<input type ="button" onclick="begin()" value = "Does anyone know what day it is?"><br />
<h3><span id = "now">&nbsp;</span></h3>
<h3><span id = "before">&nbsp;</span></h3>
<h3><span id = "later">&nbsp;</span></h3>
</body>
</html>

@ -0,0 +1,28 @@
<html>
<head>
<title>Example 7.14</title>
<script>
function startClock()
{
var today = new Date();
var hour = today.getHours(); var min = today.getMinutes(); var sec = today.getSeconds();
min = checkTime(min);
sec = checkTime(sec);
document.getElementById('now').innerHTML = ("Today's date: " + today);
document.getElementById('clock').innerHTML = hour + ":" + min + ":" + sec;
timer = setTimeout('startClock()',500);
}
function checkTime(i)
{
if (i<10)
i="0" + i;
return i;
}
</script>
</head>
<body><table align="center" width = "70%"><tr><td><br />
<input type ="button" onclick="startClock()" value = "Does anyone know what day it is?"><br />
<h3><span id = "now">&nbsp;</span></h3>
<h3><span id = "clock">&nbsp;</span></h3>
</body>
</html>

@ -0,0 +1,21 @@
<html>
<head>
<title>Example 7.15</title>
<script type="text/javascript" src="mySource.js"></script>
<script>
function shipIt()
{
var shipCode = "FREEBIE";
var userCode = prompt("Enter your code:");
if (checkWord(shipCode, userCode))
document.getElementById('result').innerHTML = ("Shipping is free!");
else
document.getElementById('result').innerHTML = ("Sorry, your code is not valid");
}
</script>
</head>
<body><table align="center" width = "70%"><tr><td><br />
<input type ="button" onclick="shipIt()" value = "Enter free shipping code"><br />
<h3><span id = "result">&nbsp;</span></h3>
</body>
</html>

@ -0,0 +1,7 @@
function checkWord(x,y)
{
var x; var y; var spell = true;
if (x != y)
spell = false;
return spell;
}

@ -0,0 +1,37 @@
<html>
<head>
<title>Example 7.16</title>
<script type="text/javascript" src="mySource.js"></script>
<script>
function shipIt()
{
var shipCode = "FREEBIE";
var userCode = prompt("Enter your code:");
if (checkWord(shipCode, userCode))
document.getElementById('result').innerHTML = ("Shipping is free!");
else
document.getElementById('result').innerHTML = ("Sorry, your code is not valid");
}
function checkWord(one, two)
{
var one; var two; var code = true;
for (i = 1; i < 4; i++)
{
code = true;
if (one != two)
{
code = false;
two = prompt("Invalid code but try again or enter Q to quit:");
if (two == "Q")
break;
}
}
return code;
}
</script>
</head>
<body><table align="center" width = "70%"><tr><td><br />
<input type ="button" onclick="shipIt()" value = "Enter free shipping code"><br />
<h3><span id = "result">&nbsp;</span></h3>
</body>
</html>

@ -0,0 +1,35 @@
<html>
<head>
<title>Example 7.17</title>
<link href="carla.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="mySource.js"></script>
<script>
function buildIt()
{
var numRows; var numCols; var table;
var filler; var filename;
numRows = parseInt(prompt("How many rows do you want in your table?"));
numCols = parseInt(prompt("How many columns do you want in your table?"));
filler = prompt("Do you want to leave the table cells empty? Type y for yes, n for no.");
if (filler == "y")
filler = "empty";
else
{
filler = prompt("Do you want the cells filled with random numbers? Type y for yes, n for no");
if (filler == "y")
filler = "random";
else
filler = "prompt";
}
filename = prompt("Enter the filename of the style sheet to use with this table:");
table = buildTable(numRows, numCols, filler, filename);
}
</script>
</head>
<body>
<div id="container">
<h1 id="logo">Table Builder</h1>
<p><input type ="button" onclick="buildIt()" value = "Build a table"></p>
</div>
</body>
</html>

@ -0,0 +1,35 @@
<html>
<head>
<title>Example 7.18a</title>
<script type="text/javascript" src="mySource.js"></script>
<script>
function getRange()
{
var num1 = parseInt(prompt("Enter low end of the range"));
var num2 = parseInt(prompt("Enter the high end of the range"));
var num3 = parseInt(prompt("Enter the number to check"));
var answer = checkRange(num3, num1, num2);
document.getElementById("line1").innerHTML = ("low end: " + num1 + "<br />");
document.getElementById("line2").innerHTML = ("high end: " + num2 + "<br />");
document.getElementById("line3").innerHTML = ("number to be checked: " + num3 + "<br />");
if (answer)
document.getElementById("line4").innerHTML = ("Number is in range");
else
document.getElementById("line4").innerHTML = ("Number is NOT in range");
}
</script>
</head>
<body>
<table align ="center" width ="70%"><tr><td colspan ="2">
<h1>&nbsp;</h2>
<h1>Get Range Function</h1>
<h3>Click to check a range</h3>
<p><input type="button" id="range" value="Enter a range" onclick="getRange();" /></p>
<div id = "line1">&nbsp; </div>
<div id = "line2">&nbsp; </div>
<div id = "line3">&nbsp; </div>
<div id = "line4">&nbsp; </div>
</td></tr>
</table></body>
</html>

@ -0,0 +1,115 @@
<html>
<head>
<title>Example 7.18b</title>
<script type="text/javascript" src="mySource.js"></script>
<script>
function getRange()
{
var num1 = parseInt(prompt("Enter low end of the range"));
var num2 = parseInt(prompt("Enter the high end of the range"));
var num3 = parseInt(prompt("Enter the number to check"));
var answer = checkRange(num3, num1, num2);
document.getElementById("line1").innerHTML = ("low end: " + num1 + "<br />");
document.getElementById("line2").innerHTML = ("high end: " + num2 + "<br />");
document.getElementById("line3").innerHTML = ("number to be checked: " + num3 + "<br />");
if (answer)
document.getElementById("line4").innerHTML = ("Number is in range");
else
document.getElementById("line4").innerHTML = ("Number is NOT in range");
}
function getPercent()
{
var num1 = parseInt(prompt("Enter the initial value"));
var num2 = parseInt(prompt("Enter the percentage discounted"));
var newVal = prompt("Enter 'new' to get the value of " + num1 + " after " + num2 + "% is taken off or enter 'reduction' to see the amount of " + num1 + " multiplied by " + num2 + "%");
if (newVal == "new")
var choice = "y";
else choice = "n";
var result = checkPercent(num1, num2, choice);
document.getElementById("line9").innerHTML = ("Initial value: " + num1 + "<br />");
document.getElementById("line10").innerHTML = ("Percentage taken: " + num2 + "%<br />");
document.getElementById("line11").innerHTML = ("Result is: " + result);
}
function getChar()
{
var theWord = prompt("Enter the word");
var letter = prompt("Enter the letter you are interested in");
var spot = parseInt(prompt("Enter the place you want to find this character"));
var answer = charAtPlace(theWord, spot, letter);
document.getElementById("line5").innerHTML = ("Your word: " + theWord + "<br />");
document.getElementById("line6").innerHTML = ("The letter: " + letter + "<br />");
document.getElementById("line7").innerHTML = ("The spot where you hope to find this letter: " + spot + "<br />");
if (answer)
document.getElementById("line8").innerHTML = ("The letter, " + letter + " is at character number " + spot + " in " + theWord);
else
document.getElementById("line8").innerHTML = ("The letter, " + letter + " is NOT at character number " + spot + " in " + theWord);
}
function checkIt()
{
var theWord = prompt("Enter the word");
var letter = prompt("Enter the letter you are interested in");
var answer = checkForChar(theWord, letter);
document.getElementById("line13").innerHTML = ("Your word: " + theWord + "<br />");
document.getElementById("line14").innerHTML = ("The letter: " + letter + "<br />");
if (answer)
document.getElementById("line15").innerHTML = ("The letter, " + letter + " is found in " + theWord);
else
document.getElementById("line15").innerHTML = ("The letter, " + letter + " is NOT found in " + theWord);
}
</script>
<style type="text/css">
<!--
body {
margin: 10%;
}
-->
</style>
</head>
<body>
<div style="width: 700px; margin-left: auto; margin-right: auto;">
<div style = "width: 300px; float: left;">
<h2>Get Range Function</h2>
<h3>Click to check a range</h3>
<p><input type="button" id="range" value="Enter a range" onclick="getRange();" /></p>
<div id = "line1">&nbsp; </div>
<div id = "line2">&nbsp; </div>
<div id = "line3">&nbsp; </div>
<div id = "line4">&nbsp; </div>
</div>
<div style = "width: 300px; float: right;">
<h2>Get Percent Function</h2>
<h3>Click to get a percent of a number</h3>
<p><input type="button" id="percent" value="Enter a number" onclick="getPercent();" /></p>
<div id = "line9">&nbsp; </div>
<div id = "line10">&nbsp; </div>
<div id = "line11">&nbsp; </div>
<div id = "line12">&nbsp; </div>
</div>
<div style="clear:both;"></div>
</div>
<div style="clear:both;"></div>
<div style="width: 700px; margin-left: auto; margin-right: auto;">
<div style = "width: 300px; float: left;">
<h2>Get One Character Check Function</h2>
<h3>Click to check if a character is in a spot in a string</h3>
<p><input type="button" id="character" value="Enter string" onclick="getChar();" /></p>
<div id = "line5">&nbsp; </div>
<div id = "line6">&nbsp; </div>
<div id = "line7">&nbsp; </div>
<div id = "line8">&nbsp; </div>
</div>
<div style = "width: 300px; float: right;">
<h2>Get Another Character Check Function</h2>
<h3>Click to check if a character is in a string</h3>
<p><input type="button" id="character" value="Enter string" onclick="checkIt();" /></p>
<div id = "line13">&nbsp; </div>
<div id = "line14">&nbsp; </div>
<div id = "line15">&nbsp; </div>
</div>
<div style="clear:both;"></div>
</div>
</body>
</html>

@ -0,0 +1,34 @@
<html>
<head>
<title>Example 7.2</title>
<script>
function quotient(x,y)
{
illegal = "Illegal division operation";
if (y != 0)
return x/y;
else
return illegal;
}
function clickIt()
{
var divTop = parseFloat(prompt("Enter the divisor:"));
var divBottom = parseFloat(prompt("Enter the dividend:"));
document.getElementById('division').innerHTML = (divTop + " divided by " + divBottom);
var division;
division = quotient(divTop, divBottom);
if (isNaN(division))
division = "illegal division operation";
else
division = division.toFixed(2);
document.getElementById('result').innerHTML = division;
}
</script>
</head>
<body>
<input type ="button" onclick="clickIt()" value = "Enter a division problem"></button>
<h2><span id = "division">&nbsp;</span></h2>
<h2>The result is: <span id = "result">&nbsp;</span></h2>
</body>
</html>

@ -0,0 +1,91 @@
<html>
<head>
<title>Example 7.3</title>
<script>
function quotient(x,y)
{
illegal = "Illegal division operation";
if (y != 0)
return x/y;
else
return illegal;
}
function divideIt()
{
var divTop = parseFloat(prompt("Enter the divisor:"));
var divBottom = parseFloat(prompt("Enter the dividend:"));
document.getElementById('division').innerHTML = (divTop + " divided by " + divBottom);
var division = quotient(divTop, divBottom);
if (isNaN(division))
division = "illegal division operation";
else
division = division.toFixed(2);
document.getElementById('result').innerHTML = division;
}
function getMileage()
{
var miles = parseFloat(prompt("How many miles did your drive on this trip?"));
var gallons = parseFloat(prompt("How many gallons of gas did you use?"));
var trip = quotient(miles, gallons);
if (isNaN(trip))
{
trip = "illegal division operation";
document.getElementById('mileage').innerHTML = ("Cannot complete the calculation. " + trip);
}
else
{
trip = trip.toFixed(1);
document.getElementById('mileage').innerHTML = ("Your mileage for this trip was " + trip + " mpg.");
}
}
function getBMI()
{
var feet = parseFloat(prompt("How tall are you? Enter your height in feet first:"));
var inches = parseFloat(prompt("How many inches over " + feet + " feet are you?"));
var height = (feet * 12 + inches);
var hInches= height * height;
var weight = parseFloat(prompt("What is your weight in pounds? You may include a partial pound, like 128.5 lbs, for example."));
document.getElementById('height').innerHTML = (height.toFixed(2));
document.getElementById('weight').innerHTML = (weight.toFixed(2));
var bmi = (quotient(weight, hInches) * 703);
if (isNaN(bmi))
{
bmi = "illegal division operation";
document.getElementById('bmi').innerHTML = ("cannot complete the calculation. " + bmi);
}
else
{
bmi = bmi.toFixed(2);
document.getElementById('bmi').innerHTML = (" " + bmi);
}
}
</script>
<style type="text/css">
<!--
body {
margin: 5%;
}
-->
</style>
</head>
<body>
<h2>Using the quotient() function</h2>
<div style="width: 80%;">
<div style="width: 50%; float: left;"><fieldset><legend>Division Problem</legend>
<input type ="button" onclick="divideIt()" value = "Enter a division problem"></button>
<h2><span id = "division">&nbsp;</span></h2>
<h2>The result is: <span id = "result">&nbsp;</span></h2></fieldset></div>
<div style=" width: 50%; float: left;"><fieldset><legend>Gas Mileage</legend>
<input type ="button" onclick="getMileage()" value = "Find the gas mileage"></button>
<h2><span id = "mileage">&nbsp;</span></h2></fieldset></div>
<div style="clear:both;"></div></div>
<br />
<div style="width: 80%;"><fieldset><legend>BMI (Body Mass Index) Calculator</legend>
<p>The formula to calculate your BMI is your weight in pounds (lbs) divided by your height in inches (in) squared and multiplied by a conversion factor of 703. But don't worry about doing the math! If you enter your weight (lbs) and height (in feet and inches), the program will calculate your BMI.</p>
<input type ="button" onclick="getBMI()" value = "Calculate your BMI (Body Mass Index)"></button>
<h3>Your height (in inches): <span id = "height">&nbsp;</span></h3>
<h3>Your weight (in pounds): <span id = "weight">&nbsp;</span></h3>
<h3>Your BMI: <span id = "bmi">&nbsp;</span></h3>
</fieldset></div>
</body>
</html>

@ -0,0 +1,25 @@
<html>
<head>
<title>Example 7.4</title>
<script>
function getAges()
{
var age = 0;
age = parseInt(prompt("How old is your grandmother?"));
pet();
function pet()
{
age = parseInt(prompt("How old is your puppy?"));
document.getElementById('puppy').innerHTML = (age +10);
}
document.getElementById('granny').innerHTML = (age + 10);
}
</script>
</head>
<body><table align="center" width = "70%"><tr><td><br />
<input type ="button" onclick="getAges()" value = "Find the age in 10 years"></button><br />
<h3>Your granny's age in 10 years: <span id = "granny">&nbsp;</span></h3>
<h3>Your puppy's age in 10 years: <span id = "puppy">&nbsp;</span></h3>
</td></tr></table>
</body>
</html>

@ -0,0 +1,26 @@
<html>
<head>
<title>Example 7.5</title>
<script>
function getAges()
{
var age = 0;
age = parseInt(prompt("How old is your grandmother?"));
pet();
function pet()
{
age = parseInt(prompt("How old is your puppy?"));
var num = 2;
document.getElementById('puppy').innerHTML = (age + 10 + num);
}
document.getElementById('granny').innerHTML = (age + 10 + num);
}
</script>
</head>
<body><table align="center" width = "70%"><tr><td><br />
<input type ="button" onclick="getAges()" value = "Find the age in 10 years"></button><br />
<h3>Your granny's age in 10 years: <span id = "granny">&nbsp;</span></h3>
<h3>Your puppy's age in 10 years: <span id = "puppy">&nbsp;</span></h3>
</td></tr></table>
</body>
</html>

@ -0,0 +1,26 @@
<html>
<head>
<title>Example 7.5</title>
<script>
function getAges()
{
var age = 0;
age = parseInt(prompt("How old is your grandmother?"));
pet();
function pet()
{
age = parseInt(prompt("How old is your puppy?"));
num = 10;
document.getElementById('puppy').innerHTML = (age + num);
}
document.getElementById('granny').innerHTML = (age + num);
}
</script>
</head>
<body><table align="center" width = "70%"><tr><td><br />
<input type ="button" onclick="getAges()" value = "Find the age in 10 years"></button><br />
<h3>Your granny's age in 10 years: <span id = "granny">&nbsp;</span></h3>
<h3>Your puppy's age in 10 years: <span id = "puppy">&nbsp;</span></h3>
</td></tr></table>
</body>
</html>

@ -0,0 +1,26 @@
<html>
<head>
<title>Example 7.5</title>
<script>
function getAges()
{
var age = 0;
age = parseInt(prompt("How old is your grandmother?"));
pet();
function pet()
{
age = parseInt(prompt("How old is your puppy?"));
var num = 10;
document.getElementById('puppy').innerHTML = (age + num);
}
document.getElementById('granny').innerHTML = (age + num);
}
</script>
</head>
<body><table align="center" width = "70%"><tr><td><br />
<input type ="button" onclick="getAges()" value = "Find the age in 10 years"></button><br />
<h3>Your granny's age in 10 years: <span id = "granny">&nbsp;</span></h3>
<h3>Your puppy's age in 10 years: <span id = "puppy">&nbsp;</span></h3>
</td></tr></table>
</body>
</html>

@ -0,0 +1,26 @@
<html>
<head>
<title>Example 7.5</title>
<script>
function getAges()
{
var age = 0;
age = parseInt(prompt("How old is your grandmother?"));
pet();
function pet()
{
var age = parseInt(prompt("How old is your puppy?"));
num = 10;
document.getElementById('puppy').innerHTML = (age + num);
}
document.getElementById('granny').innerHTML = (age + num);
}
</script>
</head>
<body><table align="center" width = "70%"><tr><td><br />
<input type ="button" onclick="getAges()" value = "Find the age in 10 years"></button><br />
<h3>Your granny's age in 10 years: <span id = "granny">&nbsp;</span></h3>
<h3>Your puppy's age in 10 years: <span id = "puppy">&nbsp;</span></h3>
</td></tr></table>
</body>
</html>

@ -0,0 +1,25 @@
<html>
<head>
<title>Example 7.6</title>
<script>
function getAges()
{
var age = 0;
age = parseInt(prompt("How old is your grandmother?"));
pet();
function pet()
{
var age = parseInt(prompt("How old is your puppy?"));
document.getElementById('puppy').innerHTML = (age +10);
}
document.getElementById('granny').innerHTML = (age + 10);
}
</script>
</head>
<body><table align="center" width = "70%"><tr><td><br />
<input type ="button" onclick="getAges()" value = "Find the age in 10 years"></button><br />
<h3>Your granny's age in 10 years: <span id = "granny">&nbsp;</span></h3>
<h3>Your puppy's age in 10 years: <span id = "puppy">&nbsp;</span></h3>
</td></tr></table>
</body>
</html>

@ -0,0 +1,48 @@
<html>
<head>
<title>Example 7.7</title>
<script>
function getDiscount()
{
var item = " ";
item = prompt("What is the item you want to buy?");
cost = parseFloat(prompt("How much does this item cost?"));
checkNum(cost);
if (cost < 50)
{
rate = .10;
salePrice = cost * (1 - rate);
}
else
if (cost < 100)
{
rate = .15;
salePrice = cost * (1 - rate);
}
else
{
rate = .20;
salePrice = cost * (1 - rate);
}
document.getElementById('item').innerHTML = item;
document.getElementById('orig_price').innerHTML = ("$ " + cost.toFixed(2));
document.getElementById('discount').innerHTML = ((rate * 100) + "%");
document.getElementById('result').innerHTML = ("$ " + salePrice.toFixed(2));
}
function checkNum(num)
{
if (num < 0)
alert("Invalid cost entered");
}
</script>
</head>
<body><table align="center" width = "70%"><tr><td><br />
<input type ="button" onclick="getDiscount()" value = "How much will you save? Find out now"></button><br />
<h3>You plan to purchase: <span id = "item">&nbsp;</span></h3>
<h3>The original cost is: <span id = "orig_price">&nbsp;</span></h3>
<h3>The discount rate is: <span id = "discount">&nbsp;</span></h3>
<h3>You pay: <span id = "result">&nbsp;</span></h3>
</td></tr></table>
</body>
</html>

@ -0,0 +1,58 @@
<html>
<head>
<title>Example 7.8</title>
<script>
function getDiscount()
{
var item = " ";
item = prompt("What is the item you want to buy?");
cost = parseFloat(prompt("How much does this item cost?"));
cost = checkNum(cost);
if (cost < 50 && cost > 0)
{
rate = .10;
salePrice = cost * (1 - rate);
}
else
if (cost >= 50 && cost < 100)
{
rate = .15;
salePrice = cost * (1 - rate);
}
else
if (cost >= 100)
{
rate = .20;
salePrice = cost * (1 - rate);
}
else
{
rate = 0;
salePrice = 0;
}
document.getElementById('item').innerHTML = item;
document.getElementById('orig_price').innerHTML = ("$ " + cost.toFixed(2));
document.getElementById('discount').innerHTML = ((rate * 100) + "%");
document.getElementById('result').innerHTML = ("$ " + salePrice.toFixed(2));
}
function checkNum(num)
{
if (num < 0)
{
alert("Invalid cost entered");
num = 0;
}
return num;
}
</script>
</head>
<body><table align="center" width = "70%"><tr><td><br />
<input type ="button" onclick="getDiscount()" value = "How much will you save? Find out now"></button><br />
<h3>You plan to purchase: <span id = "item">&nbsp;</span></h3>
<h3>The original cost is: <span id = "orig_price">&nbsp;</span></h3>
<h3>The discount rate is: <span id = "discount">&nbsp;</span></h3>
<h3>You pay: <span id = "result">&nbsp;</span></h3>
</td></tr></table>
</body>
</html>

@ -0,0 +1,28 @@
<html>
<head>
<title>Example 7.9</title>
<script>
function getValue()
{
var numMice = 12;
document.getElementById('first').innerHTML = (numMice);
changeValue(numMice);
document.getElementById('third').innerHTML = (numMice);
}
function changeValue(x)
{
x = 5;
document.getElementById('second').innerHTML = (x);
}
</script>
</head>
<body><table align="center" width = "70%"><tr><td><br />
<input type ="button" onclick="getValue()" value = "Can you change the number? Try it"><br />
<h3>The value of numMice is: <span id = "first">&nbsp;</span></h3>
<h3>The value of x, in the changeValue() function is: <span id = "second">&nbsp;</span></h3>
<h3>The value of numMice after calling the changeValue() function is: <span id = "third">&nbsp;</span></h3>
</td></tr></table>
</body>
</html>

@ -0,0 +1,118 @@
body { background-color: #000040;
background-image: url(background.gif);
color: #88ffff;
font-family: Verdana, Arial, sans-serif;
}
#container { margin-left: auto;
margin-right: auto;
width:100%;
min-width:700px;
}
#logo {
text-align:center;
margin: 0;
font-family: Geneva, Arial, Helvetica, sans-serif;
padding-top: 30px;
padding-bottom: 20px;
}
#nav {
float: left;
width: 200px;
padding-top: 10px;
text-align:left;
color: #88FFFF;
font-size: 14px;
}
#nav a {text-decoration:none;
margin: 15px;
display: block;
color: #88FFFF;
font-size: 14px;
}
#content {
margin-left: auto;
margin-right: auto;
padding: 10px;
overflow:auto;
border: medium groove #88FFFF;
line-height: 135%;
}
.floatright {padding-left:20px; padding-right:50px;
float:right;
}
.floatleft {
float:left;
padding: 30px 0px 20px;
}
#footer { font-size: .60em;
font-style: italic;
text-align: center;
border-top: 2px double #000040;
padding-top: 20px;
padding-bottom: 20px;
}
h2 { text-transform: uppercase;
color: #88ffff;
font-size: 1.2em;
border-bottom: 1px none;
margin-right: 20px;
}
h3 {
color: #88ffff;
font-size: 1em;
border-bottom: 1px solid #000000;
margin-right: auto;
text-align: left;
padding-top: 20px;
padding-right: 150px;
padding-bottom: 20px;
padding-left: 150px;
line-height: 130%;
}
.details { padding-left:20%;
padding-right:20%;
}
img {border:0; }
.content {
margin-left: auto;
margin-right: auto;
padding: 5px;
height: 3700px;
width: 500px;
}
a {text-decoration:none;
margin: 15px;
display: block;
color: #88FFFF;
font-size: 16px;
}
a:hover {
color: #000040;
background-color: #88ffff;
}
span {
font-size: 36px;
font-weight: bold;
font-family: "Courier New", Courier, mono;
color: #88ffff;
background-position: center center;
text-align: center;
vertical-align: middle;
}
table {
border-collapse: collapse
}
td {
font-family: "Courier New", Courier, mono;
font-size: 14px;
color: #88ffff;
}

@ -0,0 +1,121 @@
body { background-color: #000040;
background-image: url(background.gif);
color: #88ffff;
font-family: Verdana, Arial, sans-serif;
}
#container { margin-left: auto;
margin-right: auto;
width:80%;
min-width:700px;
}
#logo {
text-align:center;
margin: 0;
font-family: Geneva, Arial, Helvetica, sans-serif;
padding-top: 30px;
padding-bottom: 20px;
}
#nav {
float: left;
width: 200px;
padding-top: 10px;
text-align:left;
color: #88FFFF;
font-size: 12px;
}
#nav a {text-decoration:none;
margin: 15px;
display: block;
color: #88FFFF;
font-size: 12px;
}
#content {
margin-left: 150px;
padding: 30px;
overflow:auto;
border: medium groove #88FFFF;
line-height: 135%;
}
.floatright {padding-left:20px;
float:right;
}
.floatleft {
float:left;
padding: 30px 0px 20px;
}
#footer { font-size: .60em;
font-style: italic;
text-align: center;
border-top: 2px double #000040;
padding-top: 20px;
padding-bottom: 20px;
}
h2 { text-transform: uppercase;
color: #88ffff;
font-size: 1.2em;
border-bottom: 1px none;
margin-right: 20px;
}
h3 {
color: #88ffff;
font-size: 1.2em;
border-bottom: 1px solid #000000;
margin-right: auto;
text-align: left;
padding-top: 10px;
padding-right: 20px;
padding-bottom: 10px;
padding-left: 20px;
line-height: 120%;
}
.details { padding-left:20%;
padding-right:20%;
}
img {border:0; }
.content {
margin: 20px;
padding: 20px;
height: 3700px;
width: 500px;
}
a {text-decoration:none;
margin: 15px;
display: block;
color: #88FFFF;
font-size: 12px;
}
a:hover {
color: #000040;
background-color: #88ffff;
}
span {
font-size: 20px;
font-weight: bold;
font-family: "Courier New", Courier, mono;
color: #88ffff;
background-position: center center;
text-align: center;
vertical-align: middle;
}
table {
border-collapse: collapse
}
td {
border: 2px solid #88ffff;
width: 5em;
color: #88ffff;
}
.nobdr {
border: none;
cell-padding: 5px;
}

@ -0,0 +1,110 @@
<html>
<head>
<title>Greg's Gambits | Hangman</title>
<link href="greg.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="mySource.js"></script>
<script>
function startHangman()
{
var nooseCount = 0;
var wordNum = Math.floor((Math.random()*9)+1);
var picture = "pic" + wordNum + ".jpg";
switch(wordNum)
{
case 1:
word = "ghost"; break;
case 2:
word = "horse"; break;
case 3:
word = "insect"; break;
case 4:
word = "celery"; break;
case 5:
word = "pelican"; break;
case 6:
word = "jewelbox"; break;
case 7:
word = "castle"; break;
case 8:
word = "monster"; break;
case 9:
word = "bunny"; break;
}
alert("Hehehehe... We're cheater's. WORD = " + word );
var newWord = ""; var win = false;
var lgth = word.length; var guessLetter; var goodGuess = false;
for (var i = 0; i < lgth; i++)
newWord = newWord + "_ ";
document.getElementById("noose").innerHTML = ("<img src ='images/hangman0.gif' />");
document.getElementById("game").innerHTML = newWord;
while (win == false && nooseCount < 10)
{
goodGuess = false;
guessLetter = prompt("Guess a letter");
for (var j = 0; j < lgth; j++)
{
if (guessLetter == word.charAt(j))
{
goodGuess = true;
var offSet = 2*j;
newWord = setCharAt(newWord, offSet, guessLetter);
}
}
document.getElementById("game").innerHTML = newWord;
win = checkWord(word, newWord);
if (win == true)
{
document.getElementById("result").innerHTML = ("You win!");
document.getElementById("noose").innerHTML = ("<img src = '" + picture + "' />");
}
else if (win == false)
{
document.getElementById("result").innerHTML = ("not a winner yet");
if (goodGuess == false)
nooseCount = nooseCount + 1;
document.getElementById("noose").innerHTML = ("<img src ='images/hangman" + nooseCount + ".gif' />");
}
}
}
function checkWord(word, otherWord)
{
var cleanWord;
cleanWord = otherWord;
cleanWord = otherWord.replace(/ /g, "");
if (word == cleanWord)
return true;
else
return false;
}
function setCharAt(str,index,chr)
{
if(index > str.length-1)
return str;
return str.substr(0,index) + chr + str.substr(index+1);
}
</script>
</head>
<body>
<div id="container">
<img src="images/superhero.jpg" class="floatleft" />
<h1 id="logo"><em>The Game of Hangman</em></h1>
<h2 align="center">Greg Challenges You to a Game of Hangman</h2>
<p>&nbsp;</p>
<div id="nav">
<p><a href="index.html">Home</a>
<a href="greg.html">About Greg</a>
<a href="play_games.html">Play a Game</a>
<a href="sign.html">Sign In</a>
<a href="contact.html">Contact Us</a></p>
</div>
<div id="content" style="width: 600px; margin-left: auto; margin-right: auto;">
<p><input type="button" value = "Start the game" onclick="startHangman();" /></p>
<div id = "noose" class = "floatright"><img src ="images/hangman10.gif" /></div>
<div id = "game"><p>&nbsp;</p></div>
<div id = "result"><p>&nbsp;</p></div>
</div>
<div id="footer">Copyright &copy; 2013 Greg's Gambits<br />
<a href="mailto:yourfirstname@yourlastname.com">yourfirstname@yourlastname.com</a></div>
</div>
</body>
</html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 889 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

@ -0,0 +1,72 @@
function checkRange(x,low,high)
{
var x; var low; var high;
var result = true;
if (x < low || x > high)
result = false;
return result;
}
function charAtPlace(x, y, z)
{
var x; var y; var z; var result = false;
if (x.charAt(y-1) == z)
result = true;
return result;
}
function checkForChar(x, y)
{
var x; var y; var i; var lgth; var result = false;
lgth = x.length;
for (i=0; i < lgth; i++)
{
if (x.charAt(i) == y)
result = true;
}
return result;
}
function checkPercent(x, y, z)
{
var x; var y; var z; var percent;
percent = (y/100)*x;
if (z == "y")
return (x - percent);
else
return percent;
}
function checkWord(x,y)
{
var x; var y; var spell = true;
if (x != y)
spell = false;
return spell;
}
function buildTable(rows, cols, fill, style)
{
var rows; var cols; var fill; var ranNum;
var i; var j; var style;
document.write("<link href='" + style + "' rel='stylesheet' type='text/css' />");
document.write("<div id='content'><p>&nbsp;</p>");
document.write("<table width = '60%' border = '1' align = 'center' cellpadding = '5' cellspacing = '5'>");
ranNum = (rows + 1) * (cols + 1);
for (i = 0; i < rows; i++)
{
document.write("<tr>");
for (j = 0; j < cols; j++)
{
if (fill == "empty")
document.write("<td width = '" + (1/cols) + "%'><h1>&nbsp;<br /></h1> </td>");
if (fill == "random")
{
entry = parseInt(Math.random()*ranNum)+1;
document.write("<td width = '" + (1/cols) + "%'><h1>" + entry + "</h1></td>");
}
if (fill == "prompt")
{
entry = prompt("Enter a value for the cell in row " + (i + 1) + ", column " + (j + 1));
document.write("<td width = '" + (1/cols) + "%'><p>" + entry + "</p></td>");
}
}
document.write("</tr>");
}
document.write("</table> </div>");
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

@ -0,0 +1,44 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title>Greg's Gambits | Games Menu</title>
<link href="greg.css" rel="stylesheet" type="text/css" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<div id="container">
<img src="images/superhero.jpg" class="floatleft" />
<h1 id = "logo"><em>Play A Game</em></h1>
<div style ="clear:both;"></div>
<div id="nav">
<p><a href="index.html">Home</a>
<a href="greg.html">About Greg</a>
<a href="play_games.html">Play a Game</a>
<a href="sign.html">Sign In</a>
<a href="contact.html">Contact Us</a></p>
</div>
<div id="content">
<p>Menu of Available Games </p>
<table width="80%" border="0" cellpadding="5">
<tr>
<td width="50%"><a href="greg_tales.html">Greg's Tales</a> </td>
<td width="50%"><a href ="gregs_fortune.html">Madame Vadoma Sees All</a></td>
</tr>
<tr>
<td width="50%"><a href="greg_encoder.html">The Secret Message Encoder</a> </td>
<td><a href = "greg_battle.html">Battle the Evil Troll</a></td>
</tr>
<tr>
<td><a href="gregs_hangman.html">Play Hangman</a> </td>
<td>&nbsp;</td>
</tr>
</table>
<p>&nbsp;</p>
</div>
<div id="footer">Copyright &copy; 2013 Greg's Gambits<br />
<a href="mailto:yourfirstname@yourlastname.com">yourfirstname@yourlastname.com</a></div>
</div>
</body>
</html>

@ -0,0 +1,21 @@
body {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 24px;
color: #660000;
background-color: #FFEFE8;
}
h1, h2, h3 {
background-position: center;
text-align: center;
}
.floatleft {
float: left;
}
.floatright {
float: right;
}
p {
font-family: Georgia, "Times New Roman", Times, serif;
font-size: 16px;
color: #660000;
}

@ -0,0 +1,72 @@
function checkRange(x,low,high)
{
var x; var low; var high;
var result = true;
if (x < low || x > high)
result = false;
return result;
}
function charAtPlace(x, y, z)
{
var x; var y; var z; var result = false;
if (x.charAt(y-1) == z)
result = true;
return result;
}
function checkForChar(x, y)
{
var x; var y; var i; var lgth; var result = false;
lgth = x.length;
for (i=0; i < lgth; i++)
{
if (x.charAt(i) == y)
result = true;
}
return result;
}
function checkPercent(x, y, z)
{
var x; var y; var z; var percent;
percent = (y/100)*x;
if (z == "y")
return (x - percent);
else
return percent;
}
function checkWord(x,y)
{
var x; var y; var spell = true;
if (x != y)
spell = false;
return spell;
}
function buildTable(rows, cols, fill, style)
{
var rows; var cols; var fill; var ranNum;
var i; var j; var style;
document.write("<link href='" + style + "' rel='stylesheet' type='text/css' />");
document.write("<div id='content'><p>&nbsp;</p>");
document.write("<table width = '60%' border = '1' align = 'center' cellpadding = '5' cellspacing = '5'>");
ranNum = (rows + 1) * (cols + 1);
for (i = 0; i < rows; i++)
{
document.write("<tr>");
for (j = 0; j < cols; j++)
{
if (fill == "empty")
document.write("<td width = '" + (1/cols) + "%'><h1>&nbsp;<br /></h1> </td>");
if (fill == "random")
{
entry = parseInt(Math.random()*ranNum)+1;
document.write("<td width = '" + (1/cols) + "%'><h1>" + entry + "</h1></td>");
}
if (fill == "prompt")
{
entry = prompt("Enter a value for the cell in row " + (i + 1) + ", column " + (j + 1));
document.write("<td width = '" + (1/cols) + "%'><p>" + entry + "</p></td>");
}
}
document.write("</tr>");
}
document.write("</table> </div>");
}