Home arrow HTML arrow Building the Current Year with a Web Page Calendar
HTML

Building the Current Year with a Web Page Calendar


In the previous part of this eight-part series on building a web page calendar, we began a discussion of how to get the program to display any month the user wished to see. In this part, we complete that aspect of the application, and take the first step to enabling it to display an entire year. This is the fifth part of the series.

Author Info:
By: Chrysanthus Forcha
Rating: 5 stars5 stars5 stars5 stars5 stars / 1
May 11, 2009
TABLE OF CONTENTS:
  1. · Building the Current Year with a Web Page Calendar
  2. · Explanation of the receiveYearMonth() Function
  3. · Need for More Modification
  4. · Modification of the showMonth() Function Again

print this article
SEARCH DEVARTICLES

TOOLS YOU CAN USE

advertisement
Building the Current Year with a Web Page Calendar
(Page 1 of 4 )

Show any Month’s Calendar

As we indicated in the previous part, the tag for the Show any Month’s Calendar is now

<button type="button" onclick="CalJustClicked = true; receiveYearMonth()">Show any Month’s Calendar</button>

The aim of this button is to enable you to display a month of your choice. To achieve this, you need to input the year, and the month of the year (January or February --- December).

When you click the button, it calls the “receiveYearMonth()” function. This function shows a prompt (dialog) box, which receives the year. After that it prompts you, by opening another dialog box, for the month. 

This is the code for the function:


function receiveYearMonth()

{

var yearMonth = false;


var year = prompt("Please enter the year.","")

//check if the year is valid

if ((year >= 1900)&&(year.length == 4))

{

yearMonth = true;

}

else

{

alert('Year must be made up of 4 digits')

yearMonth = false;

}



if (yearMonth == true)

{

var month = prompt("Please enter the month in figures","")

 

//check if the month is valid

if ((month >= 1)&&(month <= 12))

{

yearMonth = true;

month--;

}

else

{

alert('Month must be between 1 and 12, inclusive')

yearMonth = false;

}

}


if (yearMonth == true)

{

var date = new Date(year, month,1);

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