| Sun | Mon | Tue | Wed | Thu | Fri | Sat |
|---|---|---|---|---|---|---|
| 25 | 26 | 27 | 28 | 29 | 30 | 1 |
| 2 | 3 | 4 | 5 | 6 | 7 | 8 |
| 9 | 10 | 11 | 12 | 13 | 14 | 15 |
| 16 | 17 | 18 | 19 | 20 | 21 | 22 |
| 23 | 24 | 25 | 26 | 27 | 28 | 29 |
| 30 | 31 | 1 | 2 | 3 | 4 | 5 |
Drag and Drop Calendar Selector
This javascript code is useful for selecting a range of dates from a calendar, e.g. for adding a new event to a calendar. It is not intended to create the calendar itself, that should be performed by server-side code (PHP, etc.) or some other javascript.
To use it, simply pass the calendar's id and the first date displayed to the DragDropCalendar constructor. dragDropComplete is a callback function at the end of the drag and drop operation.
Download the associated files here.
<script type="text/javascript" src="dragdrop.js"></script>
<script type="text/javascript" src="dragdropcalendar.js"></script>
<script type="text/javascript"><!--
var d = new DragDropCalendar ('calendar', new Date (2007, 10, 25));
// don't forget months in javascript are numbered 0-11, this date is November 25, the first date displayed
DragDropCalendar.prototype.dragDropComplete = function (start, end) {
if (end < start) {
var t = start;
start = end;
end = t;
}
alert ('start: ' + start + '\nend: ' + end);
}
//--></script>
Drag and Drop Calendar Selector by Geoff Lankow is licensed
under a Creative Commons Attribution 3.0 License.