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 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Feb 2003
    Location
    Chicago burbs
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    1) Is this code completely wrong 2) Can you find the missing semicolon?

    I am doing my first JS assignment, and it is not compiling with an error "expecting ';' line 20 character 30". I have a semicolon after every statement, so I'm thinking the code must be wrong. The assignment is to add a calendar to a site with the current date highlighted (among other things), so that's what all the date variables are about. I'm not getting anything to show up on the site, and when I try to open calendar.js I get the compile error.

    This is the site:
    http://jolleygood.com/ECT270/Asgn5/bcc.htm

    The calendar.js file contains the following code:
    function Calendar(caldate)
    {
    MonthName=new Array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');

    DayName=new Array('Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat');

    Calendar_Day=newDate(caldate);

    var ThisDay=Calendar_Day.getDate();
    var ThisMonth=Calendar_Day.getMonth();
    var ThisYear=Calendar_Day.getFullYear();

    document.write('<table id="calendar"><tr><th id="calendar_head" colspan="7"> "+MonthName[ThisMonth]+", "+ThisYear+" </th></tr>');

    for (i=0; i<=6; i++) {
    document.write('<tr><th class="calendar_weekdays"> "+DayName[i]+" </th></tr>');
    }

    }

    Please let me know if you can help!

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Posts
    626
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I noticed that your quotes are wrong on your document.write statements. Try changing them to this:
    document.write('<table id="calendar"><tr><th id="calendar_head" colspan="7"> '+MonthName[ThisMonth]+', '+ThisYear+' </th></tr>');

    for (i=0; i<=6; i++) {
    document.write('<tr><th class="calendar_weekdays"> '+DayName[i]+' </th></tr>');

    Because you are using single quotes to enclose your text you need to use those when you are including variables. You were using double quotes.

  • #3
    New to the CF scene
    Join Date
    Feb 2003
    Location
    Chicago burbs
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Still the same error, but thanks for the tip. I thought we had to use single quotes around the whole thing a double quotes on the variables so that it doesn't think the opening quote on the variable is the closing quote on the whole thing. I probably just made that up, though.


  •  

    Posting Permissions

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