[thelist] JS Help...again

Candace Maynard Candace.Maynard at popart.com
Tue Feb 13 17:04:46 CST 2001


var PropVal = AllProperties[2].name;
		document.write (PropVal)

This is only going to work if you
have defined 'name' as an object
before you attempt to execute this.

JS is an interpreted language, so 
it goes line by line.  If, when this
line is read, the object is not yet
defined, there is no way for the parser
to do what you ask, even if you define
name in the very next line.

So.. that means that if you put
your JavaScript at the bottom of the page,
it will be read AFTER the form is read.

***********************
On the advice of one of the more literate JS programmers here, I got the
JS
Bible and have been going through the exercises and actually getting it
for
the first time.

There's this one elementary concept that just doesn't make sense
though...over and over again, I try to construct references to objects
that
aren't recognized. That null or undefined error is ready to have me
throw a
brick through my monitor.

For instance...

// these array elements reference
// hidden form fields, in the form named form1, in a document
// in the frame named topFrame, in the parent....
var AllProperties = new Array(22)
AllProperties[0] = parent.topFrame.document.form1.tavares_bay_home
AllProperties[1] = parent.topFrame.document.form1.tropical_hideaway
AllProperties[2] = parent.topFrame.document.form1.rays_hanawi
...

But no...I get an error from the first line in the array creation
telling me
that 'parent.topFrame.document.form1.tavares_bay_home ' is null or not
an
object. Why? The path of reference through the DOM looks right to me?

and this...

var PropVal = AllProperties[2].name;
		document.write (PropVal)

Would write the name of the 3rd object in that array, one would think.

But I get another error saying AllProperties.2.name is null or not an
object...great!

I'm in serious trouble when I can't even get past the simple creation of
an
array to loop through looking for 'true' values...geez! I feel like if I
could just grasp the way you're supposed to refer to objects, I could do
it...everything else makes sense.




More information about the thelist mailing list