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","Mon","Tue","Wed","Thu","Fri","Sat")
var montharray=new
Array("Jan","Feb","Mar","Apr","May","Jun","Jul","A ug","Sep","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+" " +
' </td><td> ' + ae[i][1] + '</td></tr>');
document.write('<tr><td colspan="2"> </td></tr>');
}
}
document.write('</table>'); 6 1630
"Treetop" <tr*****@netfront.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>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+" " + ' </td><td> ' + ae[i][1] + '</td></tr>'); document.write('<tr><td colspan="2"> </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.
On Thu, 22 Jan 2004 09:25:15 -0600, Treetop <tr*****@netfront.net> wrote:
[indentation and new lines fixed; whitespace added between operators] var today = new Date(); var dayarray = new Array("Sun","Mon","Tue","Wed","Thu","Fri","Sat") var montharray = new Array("Jan","Feb","Mar","Apr","May","Jun", "Jul","Aug","Sep","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 + " " + ' </td><td> ' + ae[i][1] + '</td></tr>'); document.write('<tr><td colspan="2"> </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.******@blueyonder.co.invalid (replace ".invalid" with ".uk" to reply)
"Treetop" <tr*****@netfront.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>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])
You only put values in elements 9 and 10. So when i = 8, ae[8] is null
and ae[8][0] is undefined.
"Michael Winter" <M.******@blueyonder.co.invalid> wrote in message
news:op**************@news-text.blueyonder.co.uk... On Thu, 22 Jan 2004 09:25:15 -0600, Treetop <tr*****@netfront.net>
wrote: [indentation and new lines fixed; whitespace added between
operators] var today = new Date(); var dayarray = new
Array("Sun","Mon","Tue","Wed","Thu","Fri","Sat") var montharray = new Array("Jan","Feb","Mar","Apr","May","Jun", "Jul","Aug","Sep","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 + " " + ' </td><td> ' + ae[i][1] + '</td></tr>'); document.write('<tr><td colspan="2"> </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.
> > - 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
On Thu, 22 Jan 2004 19:49:26 GMT, Treetop <tr*****@netfront.net> wrote: "Michael Winter" <M.******@blueyonder.co.invalid> 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.******@blueyonder.co.invalid (replace ".invalid" with ".uk" to reply) This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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 =...
|
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...
|
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...
|
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)...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
| |