I've been trying for the past hour to iron out the issue(s) with this. I keep thinking that I have it just about there, try to change something here or there and still don't have it working. ANY help I could get on this would be so fantastic.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtmll/DTD/xhtmll-transitional.dtd">
<html />
<head />
<title />Gross Salary Calculator</title>
<script type="text/javascript">
<!-- HIDE FROM INCOMPATIBLE BROWSERS
var hours = "";
	if (hours = >40)
	window.alert("<p>Your regular hours must be 40 or less.<br />Anything above that should go into the overtime field.</p>");
var ot = "";
	if (hours = <40)
	window.alert("<p>In order to be paid overtime, you must enter 40 in the hours field.</p>");
var hourly = 14.38;
var total = "";
function updateTotal(value) {
	total += value;
	document.Gross_Pay.Input.value = total;
	}
// STOP HIDING FROM INCOMPATIBLE BROWSERS -->
</script>
</head>
<body />

<p><h3>Enter the hours you worked this week below.<br />
If you worked no overtime this week, leave the "0" indicating such.<br />
Your pay will be determined based on your $14.38 hourly pay rate.</h3></p><br /><br />

<table width="80%" border="0" align="center" cellspacing="5">
<tr><td width="30%">
<form name="Gross_Pay" action="" />
<label>Hours:<br />
<input type="text" name="hours" size="3" maxlength="2" /><br /><br /></label>
<label>Overtime:<br />
<input type="text" name="ot" size="3" maxlength="2" value="0" /><br /><br /></label>
<input type="button" name="calc" value="Calculate" onclick="document.Gross_Pay.Input.value=eval(total); total='(hours * hourly) + (hourly * 1.5 * ot)'" />
</form>
</td>

<td width="70%" valign="top" halign="left">
<script type="text/javascript">
<!-- HIDE FROM INCOMPATIBLE BROWSERS
document.write("<p> Your gross pay for this week<br /> will be " + total + "</p>");
// STOP HIDING FROM INCOMPATIBLE BROWSERS -->
</script>
</td></tr></table>

</body>
</html>

First validate your document against your DOCTYPE here, do away with the issues which the validator spits out and then repost. I guess this is the second time I would be telling you that <html /> is incorrect. The validator ought to tell you a lot about your code.

Okay, it has passed. Now, when I attempt to run it, I'm told that Line 37, Character 1 has an error & that document.Gross_Pay.Input is null or not an object.

Javascript is case sensitive. And anyways there is no property input, it's 'value'. And the way you are accessing form elements is wrong.

Follow the links specified in this post and read them thoroughly.

This article has been dead for over six months. Start a new discussion instead.