Web Analytics Made Easy -
StatCounter get an error with getTime() method - CodingForum

Announcement

Collapse
No announcement yet.

get an error with getTime() method

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Resolved 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; Sep 11, 2011, 11:39 AM.

  • #2
    You need to show how you're calling the yearly function and how you derive the parameter you pass to it.

    Comment


    • #3
      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>

      Comment


      • #4
        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" ) );

        Comment


        • #5
          yes i forgot to use a date object. managed to get this fixed thanks. now on the next assignment.

          Comment

          Working...
          X
          😀
          🥰
          🤢
          😎
          😡
          👍
          👎