...

View Full Version : Resolved get an error with getTime() method



bigjim27
09-11-2011, 09:41 AM
Ok so this is for school i do not want the answer i just need to be pointed in the right direction. i have been reading as much as i can to get this figured out but i am running out of time to get this done and i still have plenty of other work to do.

This is the error i get
uncaught TypeError object has no method 'getTime'

I cant figure out what is causing this. i have removed the line and the error moves to the next one down which is the getFullYear method. I am thinking i screwed something up big time but i just cant see it.




function yearly(calendarDay) {
if (calendarDay == "") {
calendarDay = currentTime.getday();
}else{
calendarDay = calendarDay;
}

var currentTime = calendarDay.getTime();
var thisYear = calendarDay.getFullYear();

document.write("<table id='yearly_table'><tr>");
document.write("<th id='yearly_title' colspan='4'>");
document.write(thisYear());
document.write("</th>");
document.write("</tr>");

var monthNum = -1;

for (var i=1; i<3; i++){
document.write("<tr>");

for(var j=1; j<4; j++){
monthNum++;
calendarDay.setDate(1);
calendarDay.setmonth(monthNum);
writeMonth(calendarDay, currentTime);
}
document.write("</tr>");
}
document.write("</table>");
}

function writeMonthCell(calendarDay, currentTime) {
document.write("<td class='yearly_months'>");
writeMonth(calendarDay, currentTime);
document.write("</td>");
}

Logic Ali
09-11-2011, 10:03 AM
You need to show how you're calling the yearly function and how you derive the parameter you pass to it.

bigjim27
09-11-2011, 10:10 AM
the page from the book just says to to call the function itself with a date of june 7, 2011 so here is the file it goes into to



<?xml version="1.0" encoding="UTF-8" ?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<!--
New Perspectives on HTML, XHTML, and DHTML
Tutorial 12
Review Assignment

The Chamberlain Civic Center Yearly Calendar

Filename: calendar.htm
Supporting files: back.jpg, ccc.jpg, photo.jpg, styles.css, yearly.css, yearly.js
-->
<title>Yearly Calendar</title>
<link href="styles.css" rel="stylesheet" type="text/css" />
<link href="yearly.css" rel="stylesheet" type="text/css" />
<script src="yearly.js" type="text/javascript"></script>

</head>

<body>
<div id="head">
<img style="float: right; border: 1px solid orange" src="photo.jpg" alt="" />
<img src="ccc.jpg" alt="Chamberlain Civic Center" />

</div>

<div id="links">
<table><tr>
<td><a href="#">Home</a></td><td><a href="#">Tickets</a></td>
<td><a href="#">Events</a></td><td><a href="#">Directions</a></td>
<td><a href="#">Hours</a></td><td><a href="#">Calendar</a></td>
<td><a href="#">Tour</a></td><td><a href="#">Contact Us</a></td>
</tr></table>
</div>

<div id="main">
<h1>Yearly Calendar</h1>
<script type="text/javascript">
yearly("june 7, 2011");
</script>
</div>

<address>
The Chamberlain Civic Center &nbsp;&#183;&nbsp;
2011 Canyon Drive &nbsp;&#183;&nbsp;
Chamberlain, SD 57325 &nbsp;&#183;&nbsp;
(800) 555-8741
</address>

</body>
</html>

Logic Ali
09-11-2011, 05:18 PM
the page from the book just says to to call the function itself with a date of june 7, 2011

That function is expecting a Date object:

yearly( new Date( "june 7, 2011" ) );

bigjim27
09-11-2011, 05:38 PM
yes i forgot to use a date object. managed to get this fixed thanks. now on the next assignment.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum