DC_Kelly
September 28th, 2005, 01:39 AM
Hey, I am sorta new here and in need of help. I have course in javascript for college, and before this course I had never looked at javascript before. Unfortunately for me, and the rest of my class for that matter, my teacher doesn't really teach. He shows us what he wants, and then we have to figure out how to do that. Which is sort of redundant because I am paying 10k a year to learn, not surf the net trying to teach something to myself. I have e-mailed him with hopes of setting up some time for me to try and learn it one on one, however until that is set up I have no other method of learning aside from somewhere like this. Anyways, I am having some calculator woes. I have been running into the following error"
Script Error (Code 0):
Line 20, Column 1
'FKeyPad.current_num' is null or not an object
I understand that the error is on line twenty, however I don't understand what it is trying to say, as I said, I am not fimilar with javascript errors and my teacher has failed to intstruct us on what to do if this error were to appear. This is my whole script. It is largely based off a tutorial I had found, as it was the closest learning tool I had. I am sorry the code is so long, I just need help, and am so lost I don't know where to start.
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
var FKeyPad = document.Keypad;
var Accum = 0;
var FlagNewNum = false;
var PendingOp = "";
function NumPressed (Num) {
if (FlagNewNum) {
FKeyPad.ReadOut.value = Num;
FlagNewNum = false;
}
else {
if (FKeyPad.current_num.value == "0")
FKeyPad.current_num.value = Num;
else
FKeyPad.current_num.value += Num;
}
}
function Operation (Op) {
var ReadOut = FKeyPad.ReadOut.value;
if (FlagNewNum && PendingOp != "=");
else
{
FlagNewNum = true;
if ( '+' == PendingOp )
Accum += parseFloat(Readout);
else if ( '-' == PendingOp )
Accum -= parseFloat(Readout);
else if ( '/' == PendingOp )
Accum /= parseFloat(Readout);
else if ( '*' == PendingOp )
Accum *= parseFloat(Readout);
else
Accum = parseFloat(Readout);
FKeyPad.ReadOut.value = Accum;
PendingOp = Op;
}
}
function Decimal () {
var curReadOut = FKeyPad.ReadOut.value;
if (FlagNewNum) {
curReadOut = "0.";
FlagNewNum = false;
}
else
{
if (curReadOut.indexOf(".") == -1)
curReadOut += ".";
}
FKeyPad.ReadOut.value = curReadOut;
}
function ClearEntry () {
FKeyPad.ReadOut.value = "0";
FlagNewNum = true;
}
function Clear () {
Accum = 0;
PendingOp = "";
ClearEntry();
}
function Neg () {
FKeyPad.ReadOut.value = parseFloat(FKeyPad.ReadOut.value) * -1;
}
function Percent () {
FKeyPad.ReadOut.value = (parseFloat(FKeyPad.ReadOut.value) / 100) * parseFloat(Accum);
}
// End -->
</SCRIPT>
</head>
<body>
<form action="./index.html" method="post" name="KeyPad">
<table width="200" border="1" align="center">
<tr>
<td colspan="4">
<div align="center">My Calculator </div></td>
</tr>
<tr>
<td colspan="4">
<div align="center">
<input name="current_num" type="text" id="current_num" size="20" value="">
</div></td>
</tr>
<tr>
<td colspan="4">
<div align="center">
<input name="ReadOut" type="text" id="Readout" size="20">
</div></td>
</tr>
<tr>
<td><input name="but7" type="button" value=" 7 " onclick="NumPressed(7)"></td>
<td><input name="but8" type="button" value=" 8 " onclick="NumPressed(8)"></td>
<td><input name="but9" type="button" value=" 9 " onclick="NumPressed(9)"></td>
<td><input name="butp" type="button" value=" + " onclick="Operation('+')"></td>
</tr>
<tr>
<td><input name="put4" type="button" value=" 4 " onclick="NumPressed(7)"></td>
<td><input name="but5" type="button" value=" 5 " onclick="NumPressed(7)"></td>
<td><input name="but6" type="button" value=" 6 " onclick="NumPressed(6)"></td>
<td><input name="buts" type="button" value=" - " onclick="Operation('-')"></td>
</tr>
<tr>
<td><input name="but1" type="button" value=" 1 " onclick="NumPressed(1)"></td>
<td><input name="but2" type="button" value=" 2 " onclick="NumPressed(2)"></td>
<td><input name="but3" type="button" value=" 3 " onclick="NumPressed(3)"></td>
<td><input name="butm" type="button" value=" * " onclick="Operation('*')"></td>
</tr>
<tr>
<td><input name="butd" type="button" value=" . " onclick="Decimal()"></td>
<td><input name="but0" type="button" value=" 0 " onclick="NumPressed(0)"></td>
<td><input name="butd" type="button" value=" / " onclick="Operation('/')"></td>
<td><input name="bute" type="button" value=" = " onclick="Operation('=')"></td>
</tr>
</table>
</form>
<p> </p>
</body>
Script Error (Code 0):
Line 20, Column 1
'FKeyPad.current_num' is null or not an object
I understand that the error is on line twenty, however I don't understand what it is trying to say, as I said, I am not fimilar with javascript errors and my teacher has failed to intstruct us on what to do if this error were to appear. This is my whole script. It is largely based off a tutorial I had found, as it was the closest learning tool I had. I am sorry the code is so long, I just need help, and am so lost I don't know where to start.
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
var FKeyPad = document.Keypad;
var Accum = 0;
var FlagNewNum = false;
var PendingOp = "";
function NumPressed (Num) {
if (FlagNewNum) {
FKeyPad.ReadOut.value = Num;
FlagNewNum = false;
}
else {
if (FKeyPad.current_num.value == "0")
FKeyPad.current_num.value = Num;
else
FKeyPad.current_num.value += Num;
}
}
function Operation (Op) {
var ReadOut = FKeyPad.ReadOut.value;
if (FlagNewNum && PendingOp != "=");
else
{
FlagNewNum = true;
if ( '+' == PendingOp )
Accum += parseFloat(Readout);
else if ( '-' == PendingOp )
Accum -= parseFloat(Readout);
else if ( '/' == PendingOp )
Accum /= parseFloat(Readout);
else if ( '*' == PendingOp )
Accum *= parseFloat(Readout);
else
Accum = parseFloat(Readout);
FKeyPad.ReadOut.value = Accum;
PendingOp = Op;
}
}
function Decimal () {
var curReadOut = FKeyPad.ReadOut.value;
if (FlagNewNum) {
curReadOut = "0.";
FlagNewNum = false;
}
else
{
if (curReadOut.indexOf(".") == -1)
curReadOut += ".";
}
FKeyPad.ReadOut.value = curReadOut;
}
function ClearEntry () {
FKeyPad.ReadOut.value = "0";
FlagNewNum = true;
}
function Clear () {
Accum = 0;
PendingOp = "";
ClearEntry();
}
function Neg () {
FKeyPad.ReadOut.value = parseFloat(FKeyPad.ReadOut.value) * -1;
}
function Percent () {
FKeyPad.ReadOut.value = (parseFloat(FKeyPad.ReadOut.value) / 100) * parseFloat(Accum);
}
// End -->
</SCRIPT>
</head>
<body>
<form action="./index.html" method="post" name="KeyPad">
<table width="200" border="1" align="center">
<tr>
<td colspan="4">
<div align="center">My Calculator </div></td>
</tr>
<tr>
<td colspan="4">
<div align="center">
<input name="current_num" type="text" id="current_num" size="20" value="">
</div></td>
</tr>
<tr>
<td colspan="4">
<div align="center">
<input name="ReadOut" type="text" id="Readout" size="20">
</div></td>
</tr>
<tr>
<td><input name="but7" type="button" value=" 7 " onclick="NumPressed(7)"></td>
<td><input name="but8" type="button" value=" 8 " onclick="NumPressed(8)"></td>
<td><input name="but9" type="button" value=" 9 " onclick="NumPressed(9)"></td>
<td><input name="butp" type="button" value=" + " onclick="Operation('+')"></td>
</tr>
<tr>
<td><input name="put4" type="button" value=" 4 " onclick="NumPressed(7)"></td>
<td><input name="but5" type="button" value=" 5 " onclick="NumPressed(7)"></td>
<td><input name="but6" type="button" value=" 6 " onclick="NumPressed(6)"></td>
<td><input name="buts" type="button" value=" - " onclick="Operation('-')"></td>
</tr>
<tr>
<td><input name="but1" type="button" value=" 1 " onclick="NumPressed(1)"></td>
<td><input name="but2" type="button" value=" 2 " onclick="NumPressed(2)"></td>
<td><input name="but3" type="button" value=" 3 " onclick="NumPressed(3)"></td>
<td><input name="butm" type="button" value=" * " onclick="Operation('*')"></td>
</tr>
<tr>
<td><input name="butd" type="button" value=" . " onclick="Decimal()"></td>
<td><input name="but0" type="button" value=" 0 " onclick="NumPressed(0)"></td>
<td><input name="butd" type="button" value=" / " onclick="Operation('/')"></td>
<td><input name="bute" type="button" value=" = " onclick="Operation('=')"></td>
</tr>
</table>
</form>
<p> </p>
</body>