Help with date functions

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nooby101
    New Member
    • Feb 2008
    • 4

    Help with date functions

    I would appreciate very much if someone could help me figure out what I am doing wrong. I have checked the code over and over and still can't figure out why it won't write to the web page. Perhaps an outside eye could help. Here goes...not sure which tags to use for .js so forgive me if I just cut/paste.

    Here's my js file:
    [CODE=javascript]function XmasDays(thisDa te) {
    var XMYear=thisDate .getFullYear();
    var XMDay=new Date("December, 25, 2005");
    XMDay.setFullYe ar(XMYear);
    var dayTotal=(XMDay-thisDate)/(1000*60*60*24) ;
    dayTotal=Math.r ound(dayTotal);
    return dayTotal;
    }

    function showDate(thisDa te){
    var thisWDay=thisDa te.getDay();
    var thisDay=thisDat e.getDate();
    var thisMonth=thisD ate.getMonth();
    var thisYear=thisDa te.getFullYear( );
    var monthName=new Array(12);
    monthName[0]="January";
    monthName[1]="February";
    monthName[2]="March";
    monthName[3]="April";
    monthName[4]="May";
    monthName[5]="June";
    monthName[6]="July";
    monthName[7]="August";
    monthName[8]="September" ;
    monthName[9]="October";
    monthName[10]="November";
    monthName[11]="December";
    var wdayName=new Array(7);
    wdayName[0]="Sunday";
    wdayName[1]="Monday";
    wdayName[2]="Tuesday";
    wdayName[3]="Wednesday" ;
    wdayName[4]="Thursday";
    wdayName[5]="Friday";
    wdayName[6]="Saturday";

    dateString="wee kday, month day, year";
    return (wdayName[thisWDay]+","monthNam e[thisMonth]+","+thisYea r);
    }


    Here's the embedded scripts:
    <td id="daycell">
    <script type="text/javascript">
    <!--Hide from non-JavaScript Browsers

    var today = new Date("Mon, Dec 24, 2008");
    var niceDate = showDate(today) ;
    var daysLeft = XmasDays(today) ;
    document.write( niceDate+"< /br>");

    if (daysLeft > 1) {
    document.write( "Only "+ daysLeft+"days until Christmas");
    }else if( daysLeft==1){
    document.write( "Last day for Christmas Shopping")
    }else{
    document.write( "Happy Holidays from North Pole Novelties");
    }

    //Stop hiding-->
    </script>[/CODE]

    here's my link:
    [HTML]<title>North Pole Novelties</title>
    <link href="styles2.c ss" rel="stylesheet " type="text/css" />
    <script src="library2.j s" type="text/javascript"></script>
    </head>[/HTML]
    Last edited by acoder; Feb 18 '08, 07:10 PM. Reason: Added code tags
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    Is the embedded script in the body?

    Comment

    • nooby101
      New Member
      • Feb 2008
      • 4

      #3
      Yes, it's in my first cell.

      Comment

      • nooby101
        New Member
        • Feb 2008
        • 4

        #4
        Any help is appreciated. Thanks

        Comment

        • vee10
          New Member
          • Oct 2006
          • 141

          #5
          Hi ,

          ur code is perfectly right but the wrong is in the showDate(thisda te) function

          the wrong is simple syntax error ie

          return (wdayName[thisWDay]+"," + monthName[thisMonth]+","+thisYea r);

          Place the bold one its enough


          Originally posted by nooby101
          I would appreciate very much if someone could help me figure out what I am doing wrong. I have checked the code over and over and still can't figure out why it won't write to the web page. Perhaps an outside eye could help. Here goes...not sure which tags to use for .js so forgive me if I just cut/paste.
          Last edited by acoder; Feb 21 '08, 10:01 AM.

          Comment

          • vee10
            New Member
            • Oct 2006
            • 141

            #6
            Hi ,

            ur code is perfectly right but the wrong is in the showDate(thisda te) function

            the wrong is simple syntax error ie

            return (wdayName[thisWDay]+"," + monthName[thisMonth]+","+thisYea r);

            Place the bold one its enough



            Originally posted by nooby101
            Any help is appreciated. Thanks

            Comment

            • nooby101
              New Member
              • Feb 2008
              • 4

              #7
              OMG!!!! Thank you soooo much! You have no idea how much this has been driving me crazy! I figured it was something very simple. Amazingly my instructor couldn't pick that up either :) You are the man!.....or woman!

              Comment

              Working...