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">
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 by php after submit the form, simple write script as the following:
<?php
$theDate = isset($_REQUEST["date1"]) ? $_REQUEST["date1"] : "";
?>
The above script should be on another 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.
To get the date selected by javascript on the current page, write script as the following:
<form action="somewhere.php" method="post" name="form1">
<?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>
<script language="javascript">
<!--
function showDateSelected(){
alert("Date selected is "+document.form1.date1.value);
}
//-->
</script>
<a href="javascript:showDateSelected();">Check calendar value</a>
Source: http://www.triconsole.com/php/calendar_datepicker.php |