39 lines
1.1 KiB
HTML
Executable File
39 lines
1.1 KiB
HTML
Executable File
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
|
<html>
|
|
<head>
|
|
<title>Example 5.15</title>
|
|
<script>
|
|
function getReceipts()
|
|
{
|
|
var week = 0; var day = 0; var subtotal = 0; var count = 0;
|
|
receipt = 0;
|
|
total = 0;
|
|
for (week = 1; week < 3; week++)
|
|
{
|
|
document.write("<h3>Week " + week + "</h3>");
|
|
count = 1; subtotal = 0;
|
|
for (day = 1; day < 8; day++)
|
|
{
|
|
receipt = parseFloat(prompt("Enter the receipts for day " + day + ": " , ""));
|
|
document.write("amount for day " + count + ": $ " + receipt.toFixed(2) + "<br />");
|
|
subtotal = subtotal + receipt;
|
|
count++;
|
|
}
|
|
document.write("<p>Week " + week + " subtotal is $ " + subtotal.toFixed(2) + "</p>");
|
|
total = total + subtotal;
|
|
}
|
|
document.write("<p>The total amount for these weeks is $ " + total.toFixed(2) + "</p>");
|
|
}
|
|
</script>
|
|
</<head>
|
|
<body>
|
|
<table align ="center" width ="70%"><tr><td colspan ="2">
|
|
<h1> </h2>
|
|
<h1>Subtotals</h1>
|
|
<h3>Click to enter receipts</h3>
|
|
<p><input type="button" id="nesting" value="Enter receipts" onclick="getReceipts();" /></p>
|
|
</td></tr>
|
|
</table></body>
|
|
</html>
|
|
|