A
abcd_68
All,
First off please note that I'm a novice at Javascript so please bear
with me.
Second, I did look at FAQs, this group, the web etc. but I'm still
stuck.
Problem is the following. I've got a fairly complex (for my abilities
at least) page with nested tables. Think of it as a small spreadsheet,
in which I have to perform computations (in Javascript of course) on a
per row basis and compute the grand totals in the bottom line. All the
rows are contained in a big form the will eventually be submitted. Upon
page loading I need to fill up arrays of references to the various
input elements so as to be able to quickly recompute totals in the
bottom line when the user changes some value. I do so by exploiting the
DOM, using constructs such as document.getElementById(), childNodes,
parent, etc.
So far so good and, as a matter of the fact, everything works perfectly
under firefox 1.5. Not so under IE 6 (on the same machine, running
WinXP SP2). Problem lies in the array initialisation. At first I used a
simple onload() function which works just fine under FF. This was not
working on IE so I set up an init() function (changed names just in
case, but the automatic association between event name and function
name does not seem to work under IE anyway) and tried all of the
following (one at a time of course):
<body onload=init>
window.onload = function () {init();}
window.onload = init
window.addEventListener('load', init, true|false)
window.attachEvent('onload', init)
Apart from addEventListener which IE frowns upon (I knew it wouldn't
work but I tried out of desperation), all the others "work" i.e., the
init function is actually called (my debugging alerts pop up). Problem
is, in all cases (under IE) said function fails to properly initialise
the arrays, issuing errors such as "childNodes is null or not an
object" and the like.
In my (possibly naive) interpretation, the root of the problem is that
when init() is called the DOM hasn't been properly initialised yet. I
try to retrieve elements by id but those elements are not completely
formed e.g., they have no children. However, this is against all that I
read about onload being fired *after* everything has been properly set
up. And again, everything is working just fine under FF so the object
references I use do make sense.
I'm stuck... Can you help?
Thanks a lot,
Andy
First off please note that I'm a novice at Javascript so please bear
with me.
Second, I did look at FAQs, this group, the web etc. but I'm still
stuck.
Problem is the following. I've got a fairly complex (for my abilities
at least) page with nested tables. Think of it as a small spreadsheet,
in which I have to perform computations (in Javascript of course) on a
per row basis and compute the grand totals in the bottom line. All the
rows are contained in a big form the will eventually be submitted. Upon
page loading I need to fill up arrays of references to the various
input elements so as to be able to quickly recompute totals in the
bottom line when the user changes some value. I do so by exploiting the
DOM, using constructs such as document.getElementById(), childNodes,
parent, etc.
So far so good and, as a matter of the fact, everything works perfectly
under firefox 1.5. Not so under IE 6 (on the same machine, running
WinXP SP2). Problem lies in the array initialisation. At first I used a
simple onload() function which works just fine under FF. This was not
working on IE so I set up an init() function (changed names just in
case, but the automatic association between event name and function
name does not seem to work under IE anyway) and tried all of the
following (one at a time of course):
<body onload=init>
window.onload = function () {init();}
window.onload = init
window.addEventListener('load', init, true|false)
window.attachEvent('onload', init)
Apart from addEventListener which IE frowns upon (I knew it wouldn't
work but I tried out of desperation), all the others "work" i.e., the
init function is actually called (my debugging alerts pop up). Problem
is, in all cases (under IE) said function fails to properly initialise
the arrays, issuing errors such as "childNodes is null or not an
object" and the like.
In my (possibly naive) interpretation, the root of the problem is that
when init() is called the DOM hasn't been properly initialised yet. I
try to retrieve elements by id but those elements are not completely
formed e.g., they have no children. However, this is against all that I
read about onload being fired *after* everything has been properly set
up. And again, everything is working just fine under FF so the object
references I use do make sense.
I'm stuck... Can you help?
Thanks a lot,
Andy