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

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();
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'>");

var monthNum = -1;

for (var i=1; i<3; i++){

for(var j=1; j<4; j++){
writeMonth(calendarDay, currentTime);

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

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.

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"

<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>


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


<div id="links">
<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>

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

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


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" ) );

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