Log In · Register

 
If ever there was a time of dire need..., Well, now wouldn't be it. -shrug-
talcumpowder
post May 13 2006, 03:13 PM
Post #1


You'll find me in your dreams.
*******

Group: Official Member
Posts: 8,536
Joined: Mar 2005
Member No: 114,010



Wanna help Reili do her homework? Okay.
[ http://www.blewmyallowanceonmanga.net/ribb...ssigned/npn.htm ]
Now, explain why my Javascript isn't working. Please.
CODE
<script type="text/javascript">
    <!-- hiding from non-javascript browsers
    var Today=new Date("October 15, 2006");
    var ThisDay=Today.getDate();
    var ThisMonth=Today.getMonth()+1;
    var ThisYear=Today.getFullYear();
    var DaysLeft=XmasDays(Today);

  document.write("Today is "+ ThisMonth +"/"+ ThisDay  +"/"+ ThisYear +"<br />");
if (DaysLeft > 0) {
  document.write("Only "+ DaysLeft +" left until Christmas!");
}

else {
  document.write("Happy Holidays from North Pole Novelties!");
}
    // stop hiding -->
</script>
^ That's in the HTML file. Then there's library.js:
CODE
/* Function: XmasDays()
   Purpose: Calcute difference between Christmas& a given date.

Variables:
   CheckDay: A date object containing the given date.
   XYear: The four-digit year value of the given date.
   XDay: December 25 in the year of the given date.
   DayCount: The number of days between Christmas and the given date.
*/

function XmasDays(CheckDay) {
    var XYear=CheckDay.getFullYear();
    var XDay=new date("December 25, 2006");
    XDay.setFullYear(XYear);
    var DayCount=(XDay-CheckDay)/(1000*60*60*24);
    DayCount=Math.round(DayCount);
    return DayCount;
}
Before I added the above function and the following section of code:
CODE
if (DaysLeft > 0) {
  document.write("Only "+ DaysLeft +" left until Christmas!");
}

else {
  document.write("Happy Holidays from North Pole Novelties!");
}
It worked. So I'm guessing I screwed up royally somewhere and I just don't see it. Or the book I was working out of screwed up. Either way.

To get really technical, I know what the problem is. Something, something "XmasDays not defined"&something, something "Date not defined". Translate?
 
 
Start new topic
Replies
talcumpowder
post May 18 2006, 08:27 PM
Post #2


You'll find me in your dreams.
*******

Group: Official Member
Posts: 8,536
Joined: Mar 2005
Member No: 114,010



Err.... Yeah... All I was doing was coping outta my book. Like, straight outta the book. It said to do that so I did.
And I know it works. That's not the problem. The problem is it only seems to work on one computer and for one person. My teacher. Whenever I fix my problems... They don't really fix anything. Then he does it on his computer and POOF! Everything's all better. >.<" What kind of crazy code is this?! T.T
 

Posts in this topic


Closed TopicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members: