Home arrow HTML arrow Page 4 - Constructing the Current Month of a Web Page Calendar
HTML

Constructing the Current Month of a Web Page Calendar


Welcome to the third part of an eight-part series on building a web page calendar. In this part, we take a close look at the showCurrentMonth() function of the calendar. It is composed of seven code segments; we'll cover the first four here. These help pull together various parts of the month for display, such as the current year.

Author Info:
By: Chrysanthus Forcha
Rating: 5 stars5 stars5 stars5 stars5 stars / 2
April 27, 2009
TABLE OF CONTENTS:
  1. · Constructing the Current Month of a Web Page Calendar
  2. · The Third Code Segment
  3. · Third Code Segment continued
  4. · The Fourth Code Segment

print this article
SEARCH DEVARTICLES

TOOLS YOU CAN USE

advertisement
Constructing the Current Month of a Web Page Calendar - The Fourth Code Segment
(Page 4 of 4 )

This is the fourth code segment:


//fill in the empty table cells with ' ' at the beginning of the month;

for (j=0;j<realStartDay;j++)

{

TDID = "M" + "0" + j;

document.getElementById(TDID).innerHTML = "&nbsp;";

}


This segment fills the empty cells at the beginning of the calendar with space characters. It uses a for-loop. It is a good habit to fill the empty cells before the first of the month, at the beginning of the calendar, with the space (&nbsp;) character. The start day (4 for example) of the week was held in the  startMonthDay variable.

The value of this variable has changed. Luckily, we copied it to the realStartDay variable. This variable indicates the day of the week where the first day of the month starts. So we have to fill the empty cells from the beginning of the first row with the space character to the day represented by this variable. That is what this code segment does.

The for-loop iterates from 0 to a number just before the value of the realStartDay variable. It cannot include the value of the realStartDay variable, since the table cell for this variable already has the number 1, the first day of the month. The first line in the for-loop creates the ID of the cell. The second line writes the space character into the cell using the ID.

We can take a break here. We continue in the next part of the series with the details of the fifth, sixth and last code segment. See you then.


DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

blog comments powered by Disqus
HTML ARTICLES

- HTML5 Boilerplate: Working with jQuery and M...
- HTML5 Boilerplate Introduction
- New API Platform for HTML5
- BBC Adopts HTML 5, Mozilla Addresses Issues
- Advanced Sticky Footers in HTML and CSS
- HTML and CSS Sticky Footers
- Strategy Analytics Predicts HTML5 Phones to ...
- HTML5 Guidelines for Web Developers
- Learning HTML5 Game Programming
- More Engaging CSS3 and HTML Background Effec...
- Engaging HTML and CSS3 Background Effects
- More Web Columns with CSS3 and HTML
- Columns with CSS3 and HTML
- Creating Inline-Block HTML Elements with CSS
- Drag and Drop in HTML5: Parsing Local Files

Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 



© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 3 - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials