Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Sep 2011
    Posts
    3
    Thanks
    1
    Thanked 0 Times in 0 Posts

    get an error with getTime() method

    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.


    Code:
    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>");
    }
    Last edited by bigjim27; 09-11-2011 at 04:39 PM.

  • #2
    Senior Coder Logic Ali's Avatar
    Join Date
    Sep 2010
    Location
    London
    Posts
    1,028
    Thanks
    0
    Thanked 207 Times in 202 Posts
    You need to show how you're calling the yearly function and how you derive the parameter you pass to it.

  • #3
    New to the CF scene
    Join Date
    Sep 2011
    Posts
    3
    Thanks
    1
    Thanked 0 Times in 0 Posts
    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

    Code:
    <?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>

  • #4
    Senior Coder Logic Ali's Avatar
    Join Date
    Sep 2010
    Location
    London
    Posts
    1,028
    Thanks
    0
    Thanked 207 Times in 202 Posts
    Quote Originally Posted by bigjim27 View Post
    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:
    Code:
    yearly( new Date( "june 7, 2011" ) );

  • Users who have thanked Logic Ali for this post:

    bigjim27 (09-11-2011)

  • #5
    New to the CF scene
    Join Date
    Sep 2011
    Posts
    3
    Thanks
    1
    Thanked 0 Times in 0 Posts
    yes i forgot to use a date object. managed to get this fixed thanks. now on the next assignment.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •