M
micahl0180
Ok, I am having trouble with the code below, but cannot seem to find the
problem. When I run it, it says Object Expected" and points me to line 31:
<form action="" method="post" name="payroll" onSubmit="earnings()">
Can anyone spot teh error in my ways. Thanks again for all your help, you
guys have been great and our making my class SOOOOOO much easier.
TIA,
ML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Chapter 4 - Scripting Exercise 5</title>
<script language="JavaScript" type="text/javscript">
<!--
// Begin function to calcualte and display weekly earnings
function earnings() {
var hrs = document.payroll.hours.value
var hrly = document.payroll.rate.value
var overtime = 0
var check = 0
var hrlypay = 0
var overtimepay = 0
parseFloat(hrs)
parseFloat(hrly)
if (hrs > 40) {
overtime = hrs - 40
hrs = 40
}
hrylpay = hrs * hrly
overtimepay = overtime * hrly
check = hrlypay + overtimepay
alert("Total Hours Worked: " + hrs + "\nRegular Pay: " + hrs + " @ $" +
hrly + "/hour = $" + hrlypay)
}
// End function to calculate and display weekly earnings
// -->
</script>
</head>
<body>
<form action="" method="post" name="payroll" onSubmit="earnings()">
<b>How many hours did you work this week?  </b>
<input type="text" name="hours" size="6" maxlength="3"><br>
<b>What is your hourly pay rate?  </b>
<input type="text" name="rate" size="6" maxlength="6"><br>
<input type="submit" name="submit" value="Calculate Earnings">  
<input type="reset" name="reset" value="Reset Form">
</form>
</body>
</html>
problem. When I run it, it says Object Expected" and points me to line 31:
<form action="" method="post" name="payroll" onSubmit="earnings()">
Can anyone spot teh error in my ways. Thanks again for all your help, you
guys have been great and our making my class SOOOOOO much easier.
TIA,
ML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Chapter 4 - Scripting Exercise 5</title>
<script language="JavaScript" type="text/javscript">
<!--
// Begin function to calcualte and display weekly earnings
function earnings() {
var hrs = document.payroll.hours.value
var hrly = document.payroll.rate.value
var overtime = 0
var check = 0
var hrlypay = 0
var overtimepay = 0
parseFloat(hrs)
parseFloat(hrly)
if (hrs > 40) {
overtime = hrs - 40
hrs = 40
}
hrylpay = hrs * hrly
overtimepay = overtime * hrly
check = hrlypay + overtimepay
alert("Total Hours Worked: " + hrs + "\nRegular Pay: " + hrs + " @ $" +
hrly + "/hour = $" + hrlypay)
}
// End function to calculate and display weekly earnings
// -->
</script>
</head>
<body>
<form action="" method="post" name="payroll" onSubmit="earnings()">
<b>How many hours did you work this week?  </b>
<input type="text" name="hours" size="6" maxlength="3"><br>
<b>What is your hourly pay rate?  </b>
<input type="text" name="rate" size="6" maxlength="6"><br>
<input type="submit" name="submit" value="Calculate Earnings">  
<input type="reset" name="reset" value="Reset Form">
</form>
</body>
</html>