M
MichiganMan
This was from a previous post, but I wanted to clean it up a bit and
repost with a final question. This is just a simple program that will
calculate a weekly salary by what is entered into the hours worked and
hourly wage text fields.
My problem is when I click to see the alert with the caculated amount,
it says "Your weekly gross salary is NaN" where NaN is supposed to be
"grossPay". I am using IE if that helps?
Any ideas? I appreciate it!
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtmll/DTD/xhtmll-transitional.dtd">
<html>
<head>
<title>Project 10-1</title>
<script type="text/javascript">
<!--HIDE FROM INCOMPATABLE BROWSERS
var hoursWorked
var hourlyWage
function grossSalaryCalc() {
if (document.wages.hoursWorked.value > 40) {
var overHours = hoursWorked -
40;
var overPay = overHours * 1.5 *
hourlyWage;
var grossPay = overPay + (hourlyWage *
40) ;
alert("Your weekly gross salary is " +
grossPay);
}
else {
var grossPay = hourlyWage * hoursWorked;
alert("Your weekly gross salary is " + grossPay);
}
}
//STOP HIDING FROM INCOMPATIBLE BROWSERS -->
</script>
</head>
<body>
<form name="wages" action="" method="get">
<p><label for="hoursWorked">Hours Worked</label> <input
type="text" name="hoursWorked" id="hoursWorked" /></p>
<p><label for="hourlyWage">Hourly Wage</label> <input type="text"
name="hourlyWage" id="hourlyWage" /></p>
<p><button type="button" onclick="grossSalaryCalc()">Calculate Gross
Salary</button>
</p>
</form>
</body>
</html>
repost with a final question. This is just a simple program that will
calculate a weekly salary by what is entered into the hours worked and
hourly wage text fields.
My problem is when I click to see the alert with the caculated amount,
it says "Your weekly gross salary is NaN" where NaN is supposed to be
"grossPay". I am using IE if that helps?
Any ideas? I appreciate it!
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtmll/DTD/xhtmll-transitional.dtd">
<html>
<head>
<title>Project 10-1</title>
<script type="text/javascript">
<!--HIDE FROM INCOMPATABLE BROWSERS
var hoursWorked
var hourlyWage
function grossSalaryCalc() {
if (document.wages.hoursWorked.value > 40) {
var overHours = hoursWorked -
40;
var overPay = overHours * 1.5 *
hourlyWage;
var grossPay = overPay + (hourlyWage *
40) ;
alert("Your weekly gross salary is " +
grossPay);
}
else {
var grossPay = hourlyWage * hoursWorked;
alert("Your weekly gross salary is " + grossPay);
}
}
//STOP HIDING FROM INCOMPATIBLE BROWSERS -->
</script>
</head>
<body>
<form name="wages" action="" method="get">
<p><label for="hoursWorked">Hours Worked</label> <input
type="text" name="hoursWorked" id="hoursWorked" /></p>
<p><label for="hourlyWage">Hourly Wage</label> <input type="text"
name="hourlyWage" id="hourlyWage" /></p>
<p><button type="button" onclick="grossSalaryCalc()">Calculate Gross
Salary</button>
</p>
</form>
</body>
</html>