473,668 Members | 2,383 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Error in Array in IE

I get the following error in IE but not in Netscape. The code works,
and the error only shows up if you click on the icon in the bottom
left corner of the screen, next to where it says Error on Page... I
would like to know what the error means and how to fix it.

The site is at www.tricityarena.com

error ae[...].0' is null or not an object

here is my code
var today = new Date();
var dayarray=new Array("Sun","Mo n","Tue","Wed", "Thu","Fri","Sa t")
var montharray=new
Array("Jan","Fe b","Mar","Apr", "May","Jun","Ju l","Aug","Sep", "Oct","Nov
","Dec")

document.write( '<table>');

var ae=new Array();

ae[10]=new Array("2004/1/16 23:59:59","<b>S tick and Puck Hockey<\/b> -
11:30am-1:00pm");
ae[9]=new Array("2004/3/26 23:59:59","<b>D iesel Football Home
Opener<\/b> vs Casper, WY - 7:30 pm");
for (var i=ae.length-1;i>=0;i--)
{
var date = new Date(ae[i][0])
var year = 1900 + date.getYear()% 1900 // < AD 3800
if (today.getTime( ) <= date.getTime()) {
document.write( '<tr><td valign=top>' + dayarray[date.getDay()]+",
"+montharra y[date.getMonth()]+" "+date.getDate( )+", "+year+" " +
'&nbsp;&nbsp; </td><td> ' + ae[i][1] + '</td></tr>');
document.write( '<tr><td colspan="2">&nb sp;</td></tr>');
}
}

document.write( '</table>');


Jul 20 '05 #1
6 1639
"Treetop" <tr*****@netfro nt.net> wrote in message
news:bu******** ****@ID-221536.news.uni-berlin.de...
I get the following error in IE but not in Netscape. The code works,
and the error only shows up if you click on the icon in the bottom
left corner of the screen, next to where it says Error on Page... I
would like to know what the error means and how to fix it.

The site is at www.tricityarena.com

error ae[...].0' is null or not an object

here is my code

[ ...snip ... ]


var ae=new Array();

ae[10]=new Array("2004/1/16 23:59:59","<b>S tick and Puck Hockey<\/b> -
11:30am-1:00pm");
ae[9]=new Array("2004/3/26 23:59:59","<b>D iesel Football Home
Opener<\/b> vs Casper, WY - 7:30 pm");
for (var i=ae.length-1;i>=0;i--)
{
var date = new Date(ae[i][0])
var year = 1900 + date.getYear()% 1900 // < AD 3800
if (today.getTime( ) <= date.getTime()) {
document.write( '<tr><td valign=top>' + dayarray[date.getDay()]+",
"+montharra y[date.getMonth()]+" "+date.getDate( )+", "+year+" " +
'&nbsp;&nbsp; </td><td> ' + ae[i][1] + '</td></tr>');
document.write( '<tr><td colspan="2">&nb sp;</td></tr>');
}
}

document.write( '</table>');


Your array contains ae[10] and ae[9] yet your 'for' loop starts and ends at
ae[1] - therein lies your problem.
Jul 20 '05 #2
On Thu, 22 Jan 2004 09:25:15 -0600, Treetop <tr*****@netfro nt.net> wrote:
[indentation and new lines fixed; whitespace added between operators]
var today = new Date();
var dayarray = new Array("Sun","Mo n","Tue","Wed", "Thu","Fri","Sa t")
var montharray = new Array("Jan","Fe b","Mar","Apr", "May","Jun" ,
"Jul","Aug","Se p","Oct","Nov", "Dec")

document.write( '<table>');

var ae = new Array();

ae[10] = new Array("2004/1/16 23:59:59",
"<b>Stick and Puck Hockey<\/b> - 11:30am-1:00pm");
ae[9] = new Array("2004/3/26 23:59:59",
"<b>Diesel Football Home Opener<\/b> vs Casper, WY - 7:30 pm");

for (var i = ae.length - 1; i >= 0; i--) {
var date = new Date( ae[i][0] )
var year = 1900 + date.getYear() % 1900 // < AD 3800
if (today.getTime( ) <= date.getTime()) {
document.write( '<tr><td valign=top>' + dayarray[date.getDay()] +
"," + montharray[date.getMonth()] + " " + date.getDate() +
", " + year + " " + '&nbsp;&nbsp; </td><td> ' + ae[i][1] +
'</td></tr>');
document.write( '<tr><td colspan="2">&nb sp;</td></tr>');
}
}

document.write( '</table>');


The algorithm, as implemented is not at fault, but your test data is. The
loop will start at 9 (the last element in the array) and attempt to
decrement to 0. This is fine, for a fully working example, but your test
data only goes to 8. As soon as the browser tries to resolve element 7, it
finds that there's no data and gives you the error. If you've only got two
pieces of test data, you can't create an array with ten elements.

Some suggestions:

- Make sure you add all the necessary semi-colons (;). There are a few
statements above that don't have them, and while technically legal (in
certain circumstances), it is still good style to include them.
- Your 'ae' array isn't much of an array. However, it would make a good
object. Consider revising it.
- Some of the forward-slashes that compose the closing tags you will
insert have been escaped, which is good. However, the majority haven't.
Make sure you change all instances of '</' to '<\/'.

Mike

--
Michael Winter
M.******@blueyo nder.co.invalid (replace ".invalid" with ".uk" to reply)
Jul 20 '05 #3
"Treetop" <tr*****@netfro nt.net> wrote in message news:<bu******* *****@ID-221536.news.uni-berlin.de>...
I get the following error in IE but not in Netscape.
Netscape is being overly friendly and hiding your bug.
error ae[...].0' is null or not an object

here is my code

var ae=new Array();

ae[10]=new Array("2004/1/16 23:59:59","<b>S tick and Puck Hockey<\/b> -
11:30am-1:00pm");
ae[9]=new Array("2004/3/26 23:59:59","<b>D iesel Football Home
Opener<\/b> vs Casper, WY - 7:30 pm");
for (var i=ae.length-1;i>=0;i--)
{
var date = new Date(ae[i][0])


You only put values in elements 9 and 10. So when i = 8, ae[8] is null
and ae[8][0] is undefined.
Jul 20 '05 #4

"Michael Winter" <M.******@bluey onder.co.invali d> wrote in message
news:op******** ******@news-text.blueyonder .co.uk...
On Thu, 22 Jan 2004 09:25:15 -0600, Treetop <tr*****@netfro nt.net> wrote:
[indentation and new lines fixed; whitespace added between operators]
var today = new Date();
var dayarray = new Array("Sun","Mo n","Tue","Wed", "Thu","Fri","Sa t") var montharray = new Array("Jan","Fe b","Mar","Apr", "May","Jun" ,
"Jul","Aug","Se p","Oct","Nov", "Dec")

document.write( '<table>');

var ae = new Array();

ae[10] = new Array("2004/1/16 23:59:59",
"<b>Stick and Puck Hockey<\/b> - 11:30am-1:00pm");
ae[9] = new Array("2004/3/26 23:59:59",
"<b>Diesel Football Home Opener<\/b> vs Casper, WY - 7:30 pm");

for (var i = ae.length - 1; i >= 0; i--) {
var date = new Date( ae[i][0] )
var year = 1900 + date.getYear() % 1900 // < AD 3800
if (today.getTime( ) <= date.getTime()) {
document.write( '<tr><td valign=top>' + dayarray[date.getDay()] + "," + montharray[date.getMonth()] + " " + date.getDate() +
", " + year + " " + '&nbsp;&nbsp; </td><td> ' + ae[i][1] +
'</td></tr>');
document.write( '<tr><td colspan="2">&nb sp;</td></tr>');
}
}

document.write( '</table>');
The algorithm, as implemented is not at fault, but your test data

is. The loop will start at 9 (the last element in the array) and attempt to
decrement to 0. This is fine, for a fully working example, but your test data only goes to 8. As soon as the browser tries to resolve element 7, it finds that there's no data and gives you the error. If you've only got two pieces of test data, you can't create an array with ten elements.
by changing the array so the last number is a 0 now did the trick.
Thanks everyone

Some suggestions:

- Make sure you add all the necessary semi-colons (;). There are a few statements above that don't have them, and while technically legal (in certain circumstances), it is still good style to include them.
The day and month arrays have semi-colons on them now. Are there any
other statements that I have missed?
- Your 'ae' array isn't much of an array. However, it would make a good object. Consider revising it.
I am affraid that I don't understand. What is an object? Is it an
element such as a VAR? ( I am very new to javascript. I learn by
taking other scripts and learning what they do, then create my own )
How is this different from an Array?
- Some of the forward-slashes that compose the closing tags you will
insert have been escaped, which is good. However, the majority haven't. Make sure you change all instances of '</' to '<\/'.


I asked this group a while ago the difference between </ and <\/ and
the impression I got is that the <\/ is not used.


Jul 20 '05 #5
> > - Your 'ae' array isn't much of an array. However, it would make a
good object. Consider revising it.
I am affraid that I don't understand. What is an object? Is it an
element such as a VAR? ( I am very new to javascript. I learn by
taking other scripts and learning what they do, then create my own )
How is this different from an Array?
This is the worst possible way to learn this language. Most of the scripts out
there are dreadful. Much of what you are learning is wrong. You are missing some
really important knowledge. You are picking up some very bad habits.

There is a good book out there by Flanagan. Get the 4th edition of it.
Meanwhile, check this out to find the difference between an object and array:
http://www.crockford.com/javascript/survey.html

The object is one of the central ideas in JavaScript. Programming without is
like driving a car without knowing what the pedals do.
- Some of the forward-slashes that compose the closing tags you will
insert have been escaped, which is good. However, the majority
haven't. Make sure you change all instances of '</' to '<\/'.

I asked this group a while ago the difference between </ and <\/ and
the impression I got is that the <\/ is not used.


You got the wrong impression. <\/ should be used in strings in html files. This
tool will help you find them all: http://www.crockford.com/javascript/lint.html

Jul 20 '05 #6
On Thu, 22 Jan 2004 19:49:26 GMT, Treetop <tr*****@netfro nt.net> wrote:
"Michael Winter" <M.******@bluey onder.co.invali d> wrote in message
news:op******** ******@news-text.blueyonder .co.uk...
- Make sure you add all the necessary semi-colons (;). There are a
few statements above that don't have them, and while technically
legal (in certain circumstances), it is still good style to include
them.


The day and month arrays have semi-colons on them now. Are there any
other statements that I have missed?


The two statement that begin "var date=" and "var year =" at the start of
the for-loop.
- Your 'ae' array isn't much of an array. However, it would make a
good object. Consider revising it.


I am affraid that I don't understand. What is an object? Is it an
element such as a VAR? ( I am very new to javascript. I learn by
taking other scripts and learning what they do, then create my own )
How is this different from an Array?


There are plenty of resources concerning the Object-Oriented Paradigm[1]
on the Internet and in books (Mr Crockford gave you one of each). Most
modern programming languages incorporate it in some way, including
JavaScript. It is certainly something worth while learning.

Briefly, objects are a way of abstracting something within a program. You
can take a complex, real-life system and break it down into properties
(attributes) that describe the entity, and the actions (methods) that it
can perform.

The arrays that your 'ae' array contained, represented events in a
recreation centre (of some description). Though not 'complex', those
events compose a real-life system, and they have properties; in this case
the time of the event and it's name.

Though possibly over-kill for something so simple, an object is a more
logical and appropriate representation for the events.
- Some of the forward-slashes that compose the closing tags you will
insert have been escaped, which is good. However, the majority
haven't. Make sure you change all instances of '</' to '<\/'.


I asked this group a while ago the difference between </ and <\/ and
the impression I got is that the <\/ is not used.


To be honest, I wasn't sure if this was another old hold-over (like script
hiding). It certainly wouldn't have done anything negative, other than
adding a byte to the file size. However, Mr Crockford just cleared that up.

The only time that you can avoid escaping the '</' sequence in a string is
in external script files. If the script is inline, you need to escape to
'<\/'.

Mike

[1] You'll also find information under Object-oriented Programming.

--
Michael Winter
M.******@blueyo nder.co.invalid (replace ".invalid" with ".uk" to reply)
Jul 20 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
66893
by: Keiron Waites | last post by:
I get the following error: Notice: Array to string conversion in C:\Documents and Settings\ShepMode\Desktop\Websites\ShareMonkey.net\Web\join.php on line 11 in this code: $input = array(array("First Name",$_POST),array("Surname"=>$_POST),array("Compan
2
2839
by: Sonoman | last post by:
Hi all: I am getting a "missing storage class or idetifier" error and I do not understand what it means, therefore and I cannot figure it out. I am just starting a new project and I cannot get past this (may be very simple) error. My code is as follows: /////////////////////////array.h #ifndef array_h #define array_h
3
4151
by: Victor | last post by:
I'm trying to run this java program, but somehow the program always quit w/o giving any error msg at all. it happenned inside the first case statements. Strangely, after printing happen2, it just stopped, and I had no idea what happens. another error is on the last function. I have already declared plane as M x N array, but it keeps giving error like hwone.cpp(50) : warning C4101: 'plane' : unreferenced local variable hwone.cpp(212) :...
0
23483
by: HKSHK | last post by:
This list compares the error codes used in VB.NET 2003 with those used in VB6. Error Codes: ============ 3: This Error number is obsolete and no longer used. (Formerly: Return without GoSub) 5: Procedure call or argument is not valid. 6: Overflow. 7: Out of memory.
669
25864
by: Xah Lee | last post by:
in March, i posted a essay “What is Expressiveness in a Computer Language”, archived at: http://xahlee.org/perl-python/what_is_expresiveness.html I was informed then that there is a academic paper written on this subject. On the Expressive Power of Programming Languages, by Matthias Felleisen, 1990. http://www.ccs.neu.edu/home/cobbe/pl-seminar-jr/notes/2003-sep-26/expressive-slides.pdf
11
1761
by: Andrew Poelstra | last post by:
I hammered this out this morning to fix inconsistancies with the way my programs handle errors. The code itself is fine, in that it compiles with Richard Heathfield's gcc tags (plus -c because it doesn't have a main). Any comments? /* Start of header */ #ifndef _ERROR_H_ #define _ERROR_H_
9
7310
by: Gary Wessle | last post by:
Hi I am trying to understand how pthread is used, so I make the scenario below, I could not understand the erros by reading the man pthread_create. //**************** code start **************** #include <iostream> #include <ctime> #include <cstdio>
9
9554
by: Trent | last post by:
Here is the error while using Visual Studio 2005 Error 1 error LNK2019: unresolved external symbol "void __cdecl print(int,int,int,int,int,int,int,int)" (?print@@YAXHHHHHHHH@Z) referenced in function _main assign2.obj Thanks a lot ! Here is the code:
5
3251
by: Al G | last post by:
Hi, I'm converting a bit of POP3 VB6 code to VB2005, and have run into this error with the following code. Can someone help me find out what I'm missing/doing wrong? 'holds the attachments Class attachmentBlockParameter
2
1985
Dormilich
by: Dormilich | last post by:
Hi, I'm testing my classes for a web page and I stumble upon an error I don't have a clue what it means: Error: Fatal error: Can't use method return value in write context in "output.php" on line 142 (line 12 in snippet) the error is caused by this call: empty($inSeite_inp->getValue('PAR_NAME')) method definition see second snippet, lines 142 to 166
0
8459
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
8378
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8890
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8791
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8577
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8653
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
4202
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4376
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2018
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.