Here's the full code, along with the script. When I open the html file, the page looks the way I want it to look, but when I enter a value and click the submit button, nothing happens. Is there something wrong in the script, or is it some simple error I missed?
<!DOCTYPE html>
<html>
<head>
<title>Question 10.10</title>
<style type="text/css">
table, table td { padding: 5px }
</style>
<script type="text/javascript>">
// initialize 4 rows 5 columns sales array
var counters = [ 0, 0, 0, 0, 0, 0, 0, 0, 0 ];
// function to collect and process sales slips
function submitSales()
{
var salary = 0; // current calculated salary
// Get values from XHTML form fields
var grossSales = parseInt( document.getElementById( "grossField" ).value );
// Validate user input gross
if ( isNaN( grossSales ) )
{
// Alert user to the error
window.alert( "Invalid gross entered!" );
return;
} // End while
// Calculate salary
salary = 200 + parseInt( ( .09 * grossSales ) );
// Increment the counter for the salary range
if ( salary >= 200 && salary <= 299 )
++counters[ 0 ];
if ( salary >= 300 && salary <= 399 )
++counters[ 1 ];
if ( salary >= 400 && salary <= 499 )
++counters[ 2 ];
if ( salary >= 500 && salary <= 599 )
++counters[ 3 ];
if ( salary >= 600 && salary <= 699 )
++counters[ 4 ];
if ( salary >= 700 && salary <= 799 )
++counters[ 5 ];
if ( salary >= 800 && salary <= 899 )
++counters[ 6 ];
if ( salary >= 900 && salary <= 999 )
++counters[ 7 ];
if ( salary >= 1000 )
++counters[ 8 ];
// output the results
displayResults();
// Reset fields in XHTML form
document.getElementById( "grossField" ).value = "0";
} // end function submitSales
// function to generate and display the weekly report
function displayResults()
{
var printoutTable = "<table border = \"1\">"; // this will hold the table to be output
printoutTable += "<tr><td colspan = \"2\" style = \"text-align: center\"><h1>Weekly Salary Range Report</h1></td></tr>";
printoutTable += "<tr><td>Range</td><td>Number of Employees</td></tr>";
printoutTable += "<tr><td>$200-299</td><td>" + counters[ 0 ] + "</td></tr>";
printoutTable += "<tr><td>$300-399</td><td>" + counters[ 1 ] + "</td></tr>";
printoutTable += "<tr><td>$400-499</td><td>" + counters[ 2 ] + "</td></tr>";
printoutTable += "<tr><td>$500-599</td><td>" + counters[ 3 ] + "</td></tr>";
printoutTable += "<tr><td>$600-699</td><td>" + counters[ 4 ] + "</td></tr>";
printoutTable += "<tr><td>$700-799</td><td>" + counters[ 5 ] + "</td></tr>";
printoutTable += "<tr><td>$800-899</td><td>" + counters[ 6 ] + "</td></tr>";
printoutTable += "<tr><td>$900-999</td><td>" + counters[ 7 ] + "</td></tr>";
printoutTable += "<tr><td>$1000+</td><td>" + counters[ 8 ] + "</td></tr>";
printoutTable += "</table>";
// send the XHTML code to the div to display the table
document.getElementById( "salesPrintout" ).innerHTML = printoutTable;
}
</script>
</head>
<body>
<form action="">
<h1>Employee Sales</h1>
<td>Gross Sales: $</td>
<td>
<input id="grossfeild" type="text"></input>
</td>
<input type="button" onclick="submitSales()" Value="Submit"></input>
<div id="salesPrintout">
<table borders="1">
<h1>Weekly Sales Report</h1>
<tr>
<td>Range</td>
<td>Number of Employees</td>
</tr>
<tr>
<td>$200-299</td>
<td>0</td>
</tr>
<tr>
<td>$300-399</td>
<td>0</td>
</tr>
<tr>
<td>$400-499</td>
<td>0</td>
</tr>
<tr>
<td>$500-599</td>
<td>0</td>
</tr>
<tr>
<td>$600-699</td>
<td>0</td>
</tr>
<tr>
<td>$700-799</td>
<td>0</td>
</tr>
<tr>
<td>$800-899</td>
<td>0</td>
</tr>
<tr>
<td>$900-999</td>
<td>0</td>
</tr>
<tr>
<td>$1000+</td>
<td>0</td>
</tr>
</body>
</html>