Home arrow HTML arrow Page 2 - Modifying a Web Page Calendar
HTML

Modifying a Web Page Calendar


Welcome to the seventh part of an eight-part series that shows you how to construct a web page calendar that will display the current month, the current year, any specified month, or any specified year. In this part of the series, I explain how the user can display the calendar of any year. To avoid writing too much code, you will have to do some modification of the previous code.

Author Info:
By: Chrysanthus Forcha
Rating: 5 stars5 stars5 stars5 stars5 stars / 1
May 26, 2009
TABLE OF CONTENTS:
  1. · Modifying a Web Page Calendar
  2. · Modification of Some Code Segments
  3. · Another Modification of the showMonth() Function
  4. · Limitations of this Approach

print this article
SEARCH DEVARTICLES

TOOLS YOU CAN USE

advertisement
Modifying a Web Page Calendar - Modification of Some Code Segments
(Page 2 of 4 )

To avoid having a lot of code, we shall modify some of our code segments so that the same segment can be used by different features of the calendars.

Modifying the removeCal() function

The aim of the removeCal() function, as we saw, was to remove the single month calendar. Well, we have to extend this to remove the yearly calendar as well. The statement that removes the single month calendar is:

document.getElementById('Cal').style.display = "none";

In the above statement, the ID of the DIV for the single month calendar is Cal. The ID for the main DIV element for the yearly calendar is YR. If you remove the main DIV element from the web page, you remove the yearly calendar.

The statement to remove the yearly calendar is placed just below the one above. The event which triggers the removal of the yearly calendar is the same as for the monthly calendar -- namely, clicking outside on the BODY element. The statement to remove the yearly calendar is:

document.getElementById('YR').style.display = "none";

Everything else in the removeCal() function remains the same. So, when you click outside on the BODY element, if the single month calendar was displayed, it would disappear; if the yearly calendar was displayed, it would disappear.

Modification of the First Button's Attribute

The call in the onclick attribute of the Show Current Month's Calendar button is now

showMonth(new Date(),'current','0')

instead of

showMonth(new Date(),'current')

This is because the showMonth(date, theMonth, monthI) now has three parameters instead of two. The parameter added is monthI. The first parameter receives the date object; the second one receives a value that indicates whether or not we are dealing with the current month. The third parameter, monthI, receives a letter that represents the month of the year.

For the onclick attribute above, the arguments for the three parameters are "new Date()", "'current'" and "'0'" respectively. The first argument is "new Date()"; the button creates the current date before sending. The second argument is "current" because we want the current month. The value 0 (that is zero) is sent here, because we want a single month calendar. I will explain how this is used in the showMonth() function shortly.

A similar modification is done for the receiveYearMonth() function, called when you click the Show any Month's Calendar button. The last statement in the receiveYearMonth() function is now

showMonth(date, "", '0');

and no longer,

showMonth(date, "");


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 11 - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials