Loading ...
Sorry, an error occurred while loading the content.

Need help with JavaScript showing days of the week

Expand Messages
  • porter_ia
    Hello, I am new and need help with a class assignment. Everything works accept the JavaScript that is supposed to show the day of the week. I get these runtime
    Message 1 of 3 , Jun 1, 2002
    • 0 Attachment
      Hello, I am new and need help with a class assignment. Everything
      works accept the JavaScript that is supposed to show the day of the
      week.

      I get these runtime errors:

      "Line 29- Expected ')'
      Line 92 - objected expected"

      Can anyone tell me what is wrong? I can't seem to locate the Line 29
      error and don't understand the line 92 problem. TIA for any help.


      Linda


      -----------------------------
      <HTML>
      <HEAD>
      <TITLE>North Pole Novelties</TITLE>
      <SCRIPT LANGUAGE="JavaScript">
      <!--- Hide from non-JavaScript browsers
      function XmasDays(CurrentDay) {
      var XYear=CurrentDay.getFullYear();
      var XDay=new Date("December, 25, 2001");
      XDay.setFullYear(XYear);
      var DayCount=(XDay-CurrentDay)/(1000*60*60*24);
      DayCount=Math.round(DayCount);
      return DayCount;
      }
      function MonthTxt (MonthNumber) {
      var Month=new Array();
      Month[1]="January";
      Month[2]="February";
      Month[3]="March";
      Month[4]="April";
      Month[5]="May";
      Month[6]="June";
      Month[7]="July";
      Month[8]="August";
      Month[9]="September";
      Month[10]="October";
      Month[11]="November";
      Month[12]="December";
      return Month[MonthNumber];
      }
      function WeekDayTxt(WeekDayNumber();{
      var WeekDay=newArray();
      WeekDay[1]="Sunday";
      WeekDay[2]="Monday";
      WeekDay[3]="Tuesday";
      WeekDay[4]="Wednesday";
      WeekDay[5]="Thursday";
      WeekDay[6]="Friday";
      WeekDay[7]="Saturday";
      returnWeekDay[WeekDayNumber];
      }
      // Stop hiding -->
      </SCRIPT>
      <STYLE>
      BODY {background-image: url(Wrap.jpg)}
      A {color: green; text-decoration:none; font-size:x-small;
      font-weight:bold; font-family: Arial, Helvetica, sans-serif}
      A:hover {color:red}
      P B {color:red}
      H3 {font-family: Arial, Helvetica, sans-serif; color:green}
      </STYLE>
      </HEAD>

      <CENTER><TABLE WIDTH=600 CELLPADDING=5 CELLSPACING=0 BORDER=1
      BGCOLOR=WHITE>
      <TR>

      <!--- Company Hyperlinks --->
      <TD VALIGN=TOP WIDTH=100 ROWSPAN=4 BGCOLOR=BLACK>
      <H5 STYLE="color:white; font-family: Arial, Helvetica, sans-serif">
      Why don't you visit our:</H5>
      <A HREF="Construct.htm">Home Page</A><BR>
      <A HREF="Construct.htm">Angels</A><BR>
      <A HREF="Construct.htm">Cards</A><BR>
      <A HREF="Construct.htm">Collectibles</A><BR>
      <A HREF="Construct.htm">Creches</A></BR>
      <A HREF="Construct.htm">Garland</A><BR>
      <A HREF="Construct.htm">Gift Wraps</A><BR>
      <A HREF="Construct.htm">Lights</A><BR>
      <A HREF="Construct.htm">Nutcrackers</A><BR>
      <A HREF="Construct.htm">Ornaments</A><BR>
      <A HREF="Construct.htm">Santas</A><BR>
      <A HREF="Construct.htm">Trains</A><BR>
      <A HREF="Construct.htm">Trees</A><BR>
      <A HREF="Construct.htm">Villages</A><BR>
      <A HREF="Construct.htm">Wreaths</A>
      </TD>

      <!--- Company Logo --->
      <TD VALIGN=TOP WIDTH=500 ALIGN=CENTER>
      <IMG SRC="Logo.jpg">
      </TD>
      </TR>
      <TR>

      <!--- Days until Christmas --->
      <TD VALIGN=TOP ALIGN=CENTER BGCOLOR=GOLD>
      <SPAN STYLE="font-size:small; font-weight:bold">
      <SCRIPT LANGUAGE="JavaScript">
      <!--- Hide from non-JavaScript browsers
      var Now=new Date();
      var ThisDay=Now.getDate();
      var ThisMonth=Now.getMonth()+1;
      var ThisYear=Now.getFullYear();
      var DaysLeft=XmasDays(Now);
      var MonthName=MonthTxt(ThisMonth);
      var Now=ThisWeekDay()+1;
      var ThisWeekDay=Now.getThisWeekDay();
      var WeekDayName=Sunday
      ShowDate(Today);
      document.write("Today is "+MonthName+" "+ThisDay+"<BR>");
      if(DaysLeft > 0) {
      document.write("Only "+DaysLeft+" days until Christmas");
      } else {
      document.write("Happy Holidays from North Pole Novelties");
      }
      // Stop hiding --->
      </SCRIPT>
      </SPAN>
      </TD>
      </TR>
      <TR>

      <!--- Articles about the company --->
      <TD>
      <TABLE BORDER=0 CELLSPACING=4 CELLPADDING=4 WIDTH=500>
      <TR>
      <!--- Welcome message --->
      <TD VALIGN=TOP WIDTH=250>
      <H3>Welcome!</H3>
      <P><IMG SRC="Bells.jpg" ALIGN=LEFT>Welcome to <B>North
      Pole Novelties</B>. Consider us your complete holiday
      store. Whether you're a collector or simply looking for a
      beautiful
      piece to treasure for years, you'll find it at NPN. Please
      click on
      one of the many links to explore all we have to offer.</P>

      <!--- Latest news --->
      <H3>News Flash!</H3>
      <P>North Pole Novelties is proud to announce a new line of
      <B>Lasseter Old Towne Village collectible houses</B>.
      Start building your collection of these wonderful miniature
      porcelain houses and shops. </P>
      <P>Each model has accessories to enhance the collection. Be
      sure to
      order extra trees, fences, street lights and signs to bring
      activity
      and a festive atmosphere to your miniature town.</P>
      </TD>

      <!--- Information about the company --->
      <TD VALIGN=TOP WIDTH=250>
      <H3>Who Are We?</H3>
      <P><IMG SRC="Watkins.jpg" ALIGN=RIGHT>Located in Seton Grove,
      Minnesota, North Pole Novelties is one of the oldest and
      largest
      holiday stores in the country. The store was founded in 1968 by
      <B>David Watkins</B> (shown here). Today,
      David, his family, and over 300 employees manage the daily
      operation
      of making the holiday season last all year.</P>
      <P>The store itself is the size of two football fields and
      attracts
      visitors from around the world. If you can't pay us a visit,
      order our
      catalogue. We will deliver to any spot in the United States and
      overseas. In a rush? We can deliver your order overnight! We
      also
      gift wrap.</P>
      </TD>
      </TR>
      </TABLE>
      </TD>
      </TR>
      <TR>

      <!--- Contact Information --->
      <TD COLSPAN=1 ALIGN=CENTER>
      <SPAN STYLE="font-size:x-small; color:green; font-weight:bold;font-
      family:sans-serif">
      North Pole Novelties<BR>
      25 Oakdale Avenue<BR>
      Seton Grove, MN     53112<BR>
      Telephone: (404) 555-1225
      </SPAN>
      </TD>
      </TR>
      </TABLE>
      </CENTER>
      <BODY>
      </HTML>
      -----------------------------------------
    • davidblackledge
      Well, I regarding your original script, I ve clipped out what you posted except for one function definition. Left by itself, it should be really clear what
      Message 2 of 3 , Jun 3, 2002
      • 0 Attachment
        Well, I regarding your original script, I've clipped out what you
        posted except for one function definition. Left by itself, it should
        be really clear what the problem is here.

        --- In javascript3@y..., "porter_ia" <porter_ia@y...> wrote:
        > "Line 29- Expected ')'
        > Line 92 - objected expected"
        >
        > Can anyone tell me what is wrong? I can't seem to locate the Line 29
        > error and don't understand the line 92 problem. TIA for any help.
        > -----------------------------
        > function WeekDayTxt(WeekDayNumber();{
        > var WeekDay=newArray();
        > WeekDay[1]="Sunday";
        > WeekDay[2]="Monday";
        > WeekDay[3]="Tuesday";
        > WeekDay[4]="Wednesday";
        > WeekDay[5]="Thursday";
        > WeekDay[6]="Friday";
        > WeekDay[7]="Saturday";
        > returnWeekDay[WeekDayNumber];
        > }
        > -----------------------------------------

        Technically, that starts on line 30 by my count... but IE isn't very
        good at determining line numbers.... maybe it starts counting at 0?

        In case it's not obvious, your function definition is all screwey...
        you turned your formal parameter (WeekDayNumber) into a function call,
        complete with a semi-colon (WeekDayNumber();) without even a closing
        paren after it to end the formal parameters. You wanted:
        function WeekDayTxt(WeekDayNumber) {
        ...
        And, your "return" is missing a space, so it's going to break badly
        also. instead of
        returnWeekDay[WeekDayNumber];
        you want
        return WeekDay[WeekDayNumber];


        David.
        http://David.Blackledge.com
      • davidblackledge
        Geez.. didn t even look further in the script... there s more. It looks like near the end, you started to lose your mind... everything else looks good until:
        Message 3 of 3 , Jun 3, 2002
        • 0 Attachment
          Geez.. didn't even look further in the script... there's more.

          It looks like near the end, you started to lose your mind...
          everything else looks good until:

          var Now=ThisWeekDay()+1;
          var ThisWeekDay=Now.getThisWeekDay();
          var WeekDayName=Sunday
          ShowDate(Today);

          1) you're re-declaring "Now" ... you already declared it, so you
          shouldn't have "var" in front of it again.
          2) ThisWeekDay is not a function, so can't put parens after it, and
          it's not even defined yet until the next line. This is probably your
          "object expected" error... ThisWeekDay is undefined, so it's not an
          object, and you're trying to call it like a function... functions are
          considered objects in IE error messages.
          3) ThisWeekDay is actually a variable that you declare in the NEXT
          line, so you'd have to swap the first and second line. You need to
          define its value (currently line 2) before you use it on the
          right-hand-side of the equation (currently in line 1).
          4) If you fix the above, you're redefining "Now" as an integer Weekday
          value... where it used to be your date object. What I think you want
          is to redefine ThisWeekDay with the added value, like
          ThisWeekDay=ThisWeekDay+1;
          5) "Sunday" is not a variable name... I assume you wanted a string...
          so you should put it in quotes.
          6) More to the point, you defined a function to give you the
          CORRECT Weekday name, so you should be calling that with your integer
          weekday number:
          var WeekDayName = WeekDayTxt(ThisWeekDay);
          7) ShowDate is not defined anywhere as a function... Neither is Today
          defined as a variable... I have no idea what the intent was there. I
          think all the functionality you want/need is in the lines following
          that statement, which are fine.
          8) After all of that, you never actually USE any of the data you were
          trying to set up in the above statements, so you could just delete
          them and the document.write lines would work fine!

          David.
        Your message has been successfully submitted and would be delivered to recipients shortly.