Demo:
Download zip file: calendar.zip (
9.77
KB.)
Version 1.8 (Last update 16 Nov 2008)
How to setup:
Only 2 steps requires for setup and use this calendar component.
Put the javascript file(.js) in the head section or somewhere else but it should be include once in a page.
<head>
<script language="javascript" src="calendar.js"></script>
</head>
Create form element in the html and put the following code
<form action="somewhere.php" method="post">
<?php
require_once('classes/tc_calendar.php');
$myCalendar = new tc_calendar("date1", true); $myCalendar->setIcon("images/iconCalendar.gif"); $myCalendar->setDate(1, 1, 2000);
$myCalendar->writeScript(); ?>
</form>
How to get the value?
To get the date selected in calendar, simple write script as the following:
<?php
$theDate = isset($_REQUEST["date1"]) ? $_REQUEST["date1"] : "";
?>
The above script should be in the file that html form point to. The parameter 'date1' is the object name that you set in the code at the time calendar construct. See further in Functions and Constructor below.
Functions
Constructor
tc_calendar (string bindObjectName)
tc_calendar (string bindObjectName, boolean date_picker)
date_picker default value is false.
Methods
setDate (int day, int month, int year)
Optional: Set default selected date to the value input. For month parameter: January=1 and December=12
Ex. $myCalendar->setDate(15, 6, 2005); //Set the date to 15 June 2005
setIcon (string url)
Optional: Set icon in date picker mode. If the icon is not set the date picker will show text as link.
Ex. $myCalendar->setIcon("images/iconCalendar.gif");
setPath (string path)
Optional: Set the path to the 'calendar_form.php' if it is not in the same directory as your script. The path string is a relative path to the script file.
Ex. $myCalendar->setPath("folder1/");
setText (string text)
Optional: Set text to display. The text will show in date picker mode when the icon is not set.
Ex. $myCalendar->setText("Click Me");
setWidth (int width)
Optional: Set width of calendar. Default value is 150 pixels
Ex. $myCalendar->setWidth(150);
setYearInterval (int year_start, int year_end)
Optional: Set the year start and year end display on calendar combo box. Default value is +15 and -15 from current year (30 years)
Ex. $myCalendar->setYearInterval(1970, 2020);
writeScript()
Write the output calendar to the screen
|