Error: (variable) is null or not an object
Error: "document.workform.person1.value" is null or not an object
I've just started with Java Script. My text book has examples that are supposed to be copy / paste / presto, learn by doing but I've been finding alot of errors. Can anyone see why this code does not work? You input 3 numbers and it should return a claculated value.
Help is appreciated.
Alison
<title>Java</title>
<meta name="Microsoft Theme" content="sandston 1011">
<meta name="Microsoft Border" content="tb, default">
</head>
<SCRIPT language = "javascript">
<!-- Begin
function groupwork( ) {
person1 = parseInt(document.workform.person1.value);
person2 = parseInt(document.workform.person2.value);
person3 = parseInt(document.workform.person3.value);
worktime = 1/((1/person1)+(1/person2)+(1/person3));
worktime = Math.round(worktime*100)/100
document.workform.time.value = worktime;
}
// End -->
</SCRIPT>
<body>
<div align="center">
<table border="0" align="left" width="787" height="79">
<tr>
<td width="204"> </td>
<td align="center" height="73" width="567">
This Calculator will tell you how long it
would take three people to complete <br>
a task if you know how long it would take each to complete the task
individually.</td>
</tr>
</table>
<p> </div>
<p align="center"> </p>
<table BORDER =0 cellspacing=3 cellpadding=3 cols=1 width="54%">
<tr>
<td>
<FORM name=workform>
<p align="right">3 Person Work Calculator::</p>
<p align="right">Person 1 can do the job in <INPUT Type="TEXT" NAME="Person1" SIZE="5"> hours.
<br> Person 2 can do the job in <INPUT Type="TEXT" NAME="Person2" SIZE="5"> hours.
<br> Person 3 can do the job in <INPUT Type="TEXT" NAME="Person3" SIZE="5"> hours.
</p>
<p align="right">
<br>Together, they can do the job in <INPUT Type="TEXT" NAME="time" SIZE="5"> hours.
</p>
<br> <INPUT TYPE="button" name="answer" VALUE="Answer!" onClick="groupwork( )" style="float: right"></p>
</form>
</td>
</tr>
<p> </p>
</table>
</body>
</html>
|