pixelmech
01-06-2004, 09:53 AM
Hello,
Trying to build a calendar and having trouble with the beginning of the month. You can see the page with the inline JS here:
http://www.pixelmech.com/review/myCal.html
Everything is fine except I cannot get the correct day to start on the correct date. I.e. , January 2004 starts on thursday, the 1st.
I end up with it starting on thursday okay, but on the 5th. I think my problem is this snippet:
// if date is not yet on correct DAY, write a blank
if(currentDay.getDate() <= firstDay.getDay())
{
calHTML += " ";
}
// otherwise write out the date
else
{
calHTML += currentDay.getDate();
}
// this line is the trouble I think - moving it into the ELSE clause = infinte loops
currentDay.setDate(currentDay.getDate() + 1);
Moving the date iterator inside the else causes an infinte loop. But keeping it in there ticks off the dates, so I always end up starting with a date later than 1 (depending on how many blank days). Any help is appreciated.
Thanks
Tom
Trying to build a calendar and having trouble with the beginning of the month. You can see the page with the inline JS here:
http://www.pixelmech.com/review/myCal.html
Everything is fine except I cannot get the correct day to start on the correct date. I.e. , January 2004 starts on thursday, the 1st.
I end up with it starting on thursday okay, but on the 5th. I think my problem is this snippet:
// if date is not yet on correct DAY, write a blank
if(currentDay.getDate() <= firstDay.getDay())
{
calHTML += " ";
}
// otherwise write out the date
else
{
calHTML += currentDay.getDate();
}
// this line is the trouble I think - moving it into the ELSE clause = infinte loops
currentDay.setDate(currentDay.getDate() + 1);
Moving the date iterator inside the else causes an infinte loop. But keeping it in there ticks off the dates, so I always end up starting with a date later than 1 (depending on how many blank days). Any help is appreciated.
Thanks
Tom