...

View Full Version : Help debugging Code



prettynpink
03-24-2009, 05:40 AM
I am trying to debug some code. I have found some typos and missing parts however now I am stuck as to what to do next in order for this to work. I added in comments at the parts of the code where I think the problems are but do not really know how to fix them.


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Days of the Week</title>
<meta http-equiv="content-type" content="text/html;
charset=iso-8859-1" />
<script type="text/javascript">
<!-- HIDE FROM INCOMPATIBLE BROWSERS
/* <![CDATA[ */
// This item is not defined. Not sure why this item here...
printDays();
/* ]]> */
// STOP HIDING FROM INCOMPATIBLE BROWSERS -->
</script>
</head>
<body>
<script type="text/javascript">
<!-- HIDE FROM INCOMPATIBLE BROWSERS
/* <![CDATA[ */
function printDays() {
var daysOfWeek = new Array(7);
daysOfWeek[0] = "Monday";
daysOfWeek[1] = "Tuesday";
daysOfWeek[2] = "Wednesday";
daysOfWeek[3] = "Thursday";
daysOfWeek[4] = "Friday";
daysOfWeek[5] = "Saturday";
daysOfWeek[6] = "Sunday";
var count = 0; //Can I use this var in the way that I am?
do {
document.write(daysOfWeek[count] + "<br />"); //would the function be called like this or with using printDays instead?
count++;
} while (count <= 6);
}
/* ]]> */
// STOP HIDING FROM INCOMPATIBLE BROWSERS -->

</script>
</body>
</html>


Thanks in advance for any info you can give me. If you can point me to a good online source for help with JavaScript that would be great. I am really new to this and my class is starting to get where I am getting a little lost.

Philip M
03-24-2009, 09:46 AM
This works fine if you get rid of the purposeless script in the <head> and use
<body onload = "printDays()">

Commenting out to "Hide from incompatible browsers" is long obsolete. I believe that problem disappeared with IE4.


Passenger to crew member as a cruise ship docked at a seaport: "What altitude is this city?"

Old Pedant
03-24-2009, 10:55 AM
Isn't it amazing how long that silly "incompatible browser" bit has hung around?? Actually, I think IE3 was okay, even.

Wouldn't have butted in but had to say "ROTFLMAO" about your quote in this one.

My son was a tour guide at the "Winchester Mystery House", a mansion built by Mrs. Winchester (heiress to the Winchester rifle company money) between about 1890 and 1910 or so. His favorite question from a tourist:
"Why did she build it so close to the freeway?"

Yeah, we really do let these people vote. *sigh*

prettynpink
03-24-2009, 07:38 PM
Thanks so much for the help. After reading it was like a oh why didn't I think of that.. I tried the body onload thing before posting and after I saw your post went back to my code which I had tried that on and realized that i spelled onload incorrectly :cool: thanks again!!!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum