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 / 3
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

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

- 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-2017 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials