Home arrow HTML arrow Showing a Full Year with a Web Page Calendar
HTML

Showing a Full Year with a Web Page Calendar


Welcome to the sixth part of an eight-part article series that shows you how to build a web page calendar. Up to now we've mostly been dealing with calculating and displaying the months. In this part of the series I talk about the layout of the calendar, and I introduce a new function that will show an entire year at a time.

Author Info:
By: Chrysanthus Forcha
Rating: 5 stars5 stars5 stars5 stars5 stars / 4
May 18, 2009
TABLE OF CONTENTS:
  1. · Showing a Full Year with a Web Page Calendar
  2. · The Show Current Year's Calendar Button
  3. · The showYear() Function
  4. · Explanation of the showYear() Function

print this article
SEARCH DEVARTICLES

Showing a Full Year with a Web Page Calendar
(Page 1 of 4 )

Layout of Calendar for the Year

We have one main DIV element. We put four of our month calendars in one row in the DIV element. Remember what I said about the IDs in the previous part of the series. Each month's calendar will be in its DIV element as it was for the single month calendar.

The IDs for the Input Text Control for the first month (January) are IA1 and IA2; those for the second month are IB1 and IB2; those for the third month are IC1 and IC2; etc. As we said, A represents January, B represents February, C represents March, and so on.

It is the single month calendar format that has been repeated for the twelve calendars. There is a small change though: in order to avoid layout problems, the Input Text elements are now part of the calendar table. A row has been added before the other rows in the calendar table. This added row has only one cell with the colspan attribute of "colspan='7'". This cell has the Input Text elements. This is the row for January:


<tr><td colspan="7"><input type="text" class="calHead" id="IA1" readonly><input type="text" class="calHead" id="IA2" readonly></td></tr>


The other months have similar rows which change only the IDs of the Input Text controls. Note that the only table cell here does not have an ID. It does not need to have one because it will not be addressed. Remember that the table cells that have the abbreviations for the days of the week also do not have IDs. They are not addressed.

Three CSS statements are added. The added statements are:


div#YR {position:absolute; left:10px; top:30px; display:none; background-color:LemonChiffon; border:2px solid black; z-index:2}

div.CalM {border:2px solid black; display:inline}

table.Inl {display:inline}


The first statement above is for the main DIV element. This is the DIV element that contains the other DIV elements for the calendars. The ID of this DIV element is YR. The style for this DIV element is the same as that for the DIV element for the single calendar.

The DIV elements for the calendars of the twelve months now have a different style. These DIV elements are grouped into a class called CalM. The second statement above defines their style.

A DIV element is a block level element, meaning that it has an inherent BR element in front and after it. In order to neutralize the effect of the inherent BR elements, you have to give the DIV element an "inline" value for its CSS display property. In that way, consecutive DIV elements will appear in a line (horizontally).

We want four DIV elements for the calendar months to appear in one line. There are 12 months in a year. This means we would have three rows of four months each for a yearly calendar. So we give the value "inline" for the CSS display property for the DIV elements of the CalM class (see the second statement above). To have the three rows, after the first set of four, we put the <br /> element. After the next set of four, we put the <br /> element. The last set of four DIV elements does not need the <br /> element, since it is at the bottom.

With what we have said so far, you should see a yearly calendar made up of three-month rows and four-month columns, if you click the appropriate button. Well, with my browser that did not work. The reason is that the TABLE element also has a line break element in front of and after it. The solution was to put all the TABLE elements for the yearly calendar into a class called Inl (third statement above) and give the elements the value of "inline" for the CSS display property. I will give you the complete code in a zip format file at the end of the series.


blog comments powered by Disqus
HTML ARTICLES

- Does HTML5 Need a Main Element?
- Revisiting the HTML5 vs. Native Debate
- HTML5: Not for Phone Apps?
- HTML5 or Native?
- Job Hunting? Freelancer.com Lists This Quart...
- HTML5 in the News
- Report: HTML5 Mobile Performance Lags
- The Top HTML5 Audio Players
- Top HTML5 Video Tutorials
- HTML5: Reasons to Learn and Use It
- More of the Top Tutorials for HTML5 Forms
- MobileAppWizard Releases HTML5 App Builder
- HTML5 Boilerplate: Working with jQuery and M...
- HTML5 Boilerplate Introduction
- New API Platform for HTML5

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 

Developer Shed Affiliates

 




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