Home arrow HTML arrow Page 3 - Creating a Web Page Calendar
HTML

Creating a Web Page Calendar


Welcome to the second part of an eight-part series on building a web page calendar. In this part of the series, I will explain the function that is used to create the current calendar. When the Show Current Month's Calendar button is clicked, it should call a function that will display the calendar of the current month. We need to modify it; the showCal() function we saw in the previous part has only one line. We will change this function and use it as the showCurrentMonth() function.

Author Info:
By: Chrysanthus Forcha
Rating: 5 stars5 stars5 stars5 stars5 stars / 1
April 20, 2009
TABLE OF CONTENTS:
  1. · Creating a Web Page Calendar
  2. · The Date Object
  3. · The showCurrentMonth() Function
  4. · Skeleton of the showCurrentMonth() Function

print this article
SEARCH DEVARTICLES

TOOLS YOU CAN USE

advertisement
Creating a Web Page Calendar - The showCurrentMonth() Function
(Page 3 of 4 )

Now that we've summarized the JavaScript Date object, we'll use it for our function. 

Array for Month Names

As we saw in the summary earlier, the date object will return the day of the week, date (month number) and month as integers. If we need the words (names), we have to do the conversion ourselves. For this series, the only thing we need to convert is the names of the months. For this we need an array.

The following global scope array is declared:


var monthArray = new Array(12);

monthArray[0] = "January";

monthArray[1] = "February";

monthArray[2] = "March";

monthArray[3] = "April";

monthArray[4] = "May";

monthArray[5] = "June";

monthArray[6] = "July";

monthArray[7] = "August";

monthArray[8] = "September";

monthArray[9] = "October";

monthArray[10] = "November";

monthArray[11] = "December";


The number (0, 2 ... 11) returned by the date object is what I have used as the index for each element of the array. The value of each element in the array is the corresponding name of the month of the year. So, if our date object returns a month value of 5, our code will use this array to know that the name for the month is June.


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