[thelist] javascript: date trouble

Tom Dell'Aringa pixelmech at yahoo.com
Tue Jan 6 09:51:26 CST 2004


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 += "&nbsp;";
}
// 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 outside 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).

Thanks

Tom

=====
http://www.pixelmech.com/ :: Web Development Services
http://www.DMXzone.com/ :: JavaScript Author / Every Friday!
http://www.thywordistruth.net/ :: Eternal Life

[Those who say that I am finished, and am through, will have to run over my dead body to beat me...]


More information about the thelist mailing list