Looking for beta testers for WhizzyInvoice.com. Wanna help? Jump to: main content, navigation or the bottom.

The Calendar

The calendar needs a JavaScript file and a CSS file which you can customise to suit your site. The JS file is only 14kb with comments. You simply put the javascript file in the <head> tag of your page and it will become available to use! See the examples below.

Usage

You can change the appearance of the calendar by simply changing the CSS to suit your needs. If you are feeling adventurous you can also dig into the JavaScript which is nicely commented so you can understand what's going on. You will have to change the CSS to suit your site as some of the other CSS you use on your pages might contradict what is in the calendar CSS - try it out and see how it goes!

Feel free to use this where you like but if it's a help to you, please drop me a line!

Examples

  1. Blue popup calendar A simple popup calendar in blue that doesn't have the nice fading effect on
  2. Orange small popup calendar Another smaller sized calendar that uses the nice fading effect

Changelog

  • 29/01/2008 - Improved and reduced code, added fade effect and added tool tips to dates
  • 30/03/2007 - First version

TODO List

  • Position the calendar differently if it spills over the viewable space.
  • Improve Code
  • Allow different date separators
  • Allow different date formats (YYYY/MM/DD and MM/DD/YYYY)
  • Allow for date restrictions

Credits

My calendar uses some code from QuirksMode.org - http://www.quirksmode.org/js/week.html


Comments (15)

What others have said about this post.

  • About 4 years ago Anup said:

    How can I change the date format to mm/dd/yy in the display? Thanks

  • About 4 years ago Stewart said:

    Hi Anup, a new version with selectable date formats is coming soon.

  • About 4 years ago Anup said:

    Thank you for the reply. I'll be looking forward for the new version. Is there any quick fix for now?

  • About 3 years ago weenaak said:

    I love the calendar, thanks! I have added some code to move the calendar if it falls off the page...

    place this code in the showCalendar function after x and y have been defined. You must also define calendarWidth and calendarHeight before this code. You have to define them based on the number of rows and cols in the table, and the widths, heights, margins and borders in the css.

    // Move the calendar if it falls off the page
    var pageWidth = 0;
    var pageHeight = 0;
    if (typeof( window.innerWidth ) == 'number' ) {
    	//Non-IE
    	pageWidth = window.innerWidth;
    	pageHeight = window.innerHeight;
    } else if( document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight) ) {
    	//IE 6+ in 'standards compliant mode'
    	pageWidth = document.documentElement.clientWidth;
    	pageHeight = document.documentElement.clientHeight;
    } else if( document.body && (document.body.clientWidth || document.body.clientHeight) ) {
    	//IE 4 compatible
    	pageWidth = document.body.clientWidth;
    	pageHeight = document.body.clientHeight;
    }
    if(x+calendarWidth > pageWidth) x = pageWidth - calendarWidth;
    if(y+calendarHeight > pageHeight) y = pageHeight - calendarHeight - 5; // subtract 5 because of the y+5 in the next line

  • About 3 years ago miss cassandra said:

    I was having problems with another calendar + IE7 ... I found yours and want to say THANKS!!! I'm in the US, so I did need to change the date format. Replace line 200 of ezcalendar.js with the following:

    getID("cell"+r+c).href = "javascript:setDateValue('" + formatNumber(calendarDate.getMonth()+1) + dateSeparator + formatNumber(calendarDate.getDate()) + dateSeparator + calendarDate.getFullYear() + "')";
    

    makes the date mm/dd/yyyy ... hope it helps anyone else looking for the easy solution - thanks again! :)

  • About 3 years ago chicas rubias said:

    nice! i'm gonna make my own blog

  • About 2 years ago Mcs said:

    Works in IE+Opera+Firefox+Safari

    that's what i looked

    THANXXXXX)))))

  • About 2 years ago chuava said:

    Very nice calendar! Saved me a lot time in coding my ERP project

  • About 2 years ago Bill said:

    Is there any way to make this calendar show up when the page loads and not have any of the form but just the calendar as a reference source for viewers on a page? I am not that good with js to know how to make it work.

  • About 2 years ago qodo said:

    Hi Bill, this is intended to update a input field when the user selects a date but you could change it so that it doesn't do anything by making a hidden input field:

    <input type="hidden" id="date1" />
    

    Last Edit: May 20, 2010, 09:22:25 by qodo  
  • About 2 years ago Juan said:

    please, i have to recieve in my input type text something like this YYY-MM-DD, any idea??

  • About 12 months ago Kaveena said:

    hello...how do i change the format to YYYY/MM/DD?

  • About 10 months ago Dimitris said:

    Hi i want report a problem with April of 2011 it displays like March. Why?

  • About 10 months ago Dimitris said:

    For date format (YYYY/MM/DD) replace line 200 of ezcalendar.js with : getID("cell"+r+c).href = "javascript:setDateValue('" + formatNumber(calendarDate.getFullYear()) + dateSeparator + formatNumber(calendarDate.getMonth()+1) + dateSeparator + calendarDate.getDate() + "')";

  • About 9 months ago moda kulvar said:

    Thanks you very much! Wonderful picker and very nice and usefully and CSS!

    Thanks again..

Got something to say?

Join the discussion! You know how these things work; enter your details and comments below and be heard.

If you have trouble reading the code, click on the code itself to generate a new random code.
 

Going up? Back to the top