Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java and JDK > JSP Basics
|
JSP Basics Beginning-level questions on JSP. More advanced coders should post to Pro JSP.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the JSP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 22nd, 2005, 02:10 PM
Authorized User
 
Join Date: Oct 2004
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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">&nbsp;</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>&nbsp;</div>
<p align="center">&nbsp;</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&nbsp; <INPUT Type="TEXT" NAME="Person1" SIZE="5"> hours.&nbsp;&nbsp;
<br> Person 2 can do the job in <INPUT Type="TEXT" NAME="Person2" SIZE="5"> hours.&nbsp;&nbsp;
<br> Person 3 can do the job in <INPUT Type="TEXT" NAME="Person3" SIZE="5"> hours.&nbsp;&nbsp;
</p>
<p align="right">&nbsp;
<br>Together, they can do the job in <INPUT Type="TEXT" NAME="time" SIZE="5"> hours.&nbsp;
</p>

<br>&nbsp;<INPUT TYPE="button" name="answer" VALUE="Answer!" onClick="groupwork( )" style="float: right"></p>
</form>
</td>
</tr>
<p>&nbsp;</p>
</table>
</body>
</html>

 
Old February 14th, 2005, 07:14 AM
Registered User
 
Join Date: Feb 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hello,

The problem is that the input boxes are differently named.

The names need the be the same case as they are in the javascript.

e.g.
person3 = parseInt(document.workform.Person1.value);
not
person3 = parseInt(document.workform.person1.value);

MR_MAN






Similar Threads
Thread Thread Starter Forum Replies Last Post
How to know if a variable is null peace2007 Javascript 9 September 30th, 2007 10:08 AM
display Null or Not an object error kishy449 Classic ASP Professional 1 September 4th, 2007 01:21 PM
Object variable or With block variable not set haidee_mccaffrey Classic ASP Professional 5 March 8th, 2007 03:34 PM
object variable or with block variable not set Aoude BOOK: Beginning VB.NET Databases 1 February 24th, 2006 05:21 PM
Error: 'style.display' is null or not an object Adam H-W Javascript 4 April 22nd, 2004 08:45 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.