Simple Calendar Creator


This script can be used to create simple calendars on your page like this:





Installation:

  1. First, copy and paste the following line of code in the <HEAD> section of your page:

    <script language="javascript" src="calender.js"></script>

  2. Next, you need to make the script write out the HTML to make the calendar(s). The way they look is based on stylesheets so there aren't too many parameters to pass to the actual calendar creating function. The example at the top of the page was created with the following code:

    <script language="javascript">
    document.write(buildCal(4,2003,"main","month","daysofweek","days",0));
    </script>


    You set up a set of Javascript tags wherever you want the calender to appear and then put the code to create the calendar inside the document.write() javascript function. This is a little more complex than it needs to be, but it allows a little more flexibility, as I will show later on.

    The highlighted parameters in the example code are explained below:
  3. Then, you define four different CSS rules for each section of the calendar and assign them arbitrary (but meaningful) classnames. Below are the CSS classnames and values I used in the example at the top of the page:

    .main {
    width:150px;
    border:1px solid black;
    }
    .month {
    background-color:black;
    font:bold 11px verdana;
    color:white;
    }
    .daysofweek {
    background-color:gray;
    font:bold 10px verdana;
    color:white;
    }
    .days {
    font-size:9px;
    font-family:verdana;
    color:black;
    background-color:lightgrey;
    }

    You can tell pretty much what classname go with which part of the calendar. I suggest you do the same to make it easy for yourself. Just play with the values to get the look you want. Be warned: due to NS4's lackluster CSS support, you may find you can't use some values and have the same look as in IE or NS6. Keep it simple unless you do not care about the people who still use NS4.



More Examples & Advanced Functions