Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Mar 2009
    Posts
    7
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Question Help debugging Code

    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.
    Code:
    <!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.

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,920
    Thanks
    203
    Thanked 2,531 Times in 2,509 Posts
    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?"

  • Users who have thanked Philip M for this post:

    prettynpink (03-24-2009)

  • #3
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,200
    Thanks
    75
    Thanked 4,342 Times in 4,308 Posts
    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*

  • #4
    New to the CF scene
    Join Date
    Mar 2009
    Posts
    7
    Thanks
    1
    Thanked 0 Times in 0 Posts
    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 thanks again!!!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •