Greetings colleagues,
I’ve boiled down my code to the essence of the problem; a variable which serves as a parameter to a function keeps coming up as ‘undefined’. The code is quite simple:
….
<head>
<title>Yearly Calendar</title>
<link href=”styles.css” rel=”stylesheet” type=”text/css” />
<link href=”yearly.css” rel=”stylesheet” type=”text/css” />
<script type=”text/javascript”>
function writeMonthCell(calandarDay, currentTime)
{
alert(typeof calendarDay);
var this_DATE=new Date(calendarDay);
document.write(“inside writeMonthCell the date is: ” + this_DATE);
}//end writeMonthCell function
</script>
</head>
<
body>
<div id=”main”>
<h1>Yearly Calendar</h1>
<script type=”text/javascript”>
var thisDate=new Date(“March 25, 2011 14:35:05”);
var thistime=thisDate.getTime();
document.write(“the date is:” + thisDate+”<br />”);
document.write(“the time is:” + thistime+”<br />”);
alert(typeof thisDate);
writeMonthCell(thisDate, thistime);
</script>
</div>
</body>
</html>
in the main body the alert(typeof thisDate) displays ‘object’; but when the function is called, writeMonthCell, inside the function the alert says ‘calendar undefined’ .
I’m perplexed; why is thisDate now undefined as a parameter?
Your comments would be very appreciated!!
captsig