How to Start with Calendar

To use dhtmlxCalendar in your application you should make 3 steps:

  1. Download the 'dhtmlxCalendar' or 'dhtmlxSuite' package and unpack it into a folder.
  2. Include the related CSS and JS files into your HTML file .
  3. Call an object constructor.

Including necessary files

Each DHTMLX component can be used standalone or as a part of the general library.

If you use dhtmlxCalendar standalone you need to include 2 files:

  • dhtmlxcalendar.js
  • dhtmlxcalendar.css
<!DOCTYPE html>
        <link type="text/css" href="../codebase/dhtmlxcalendar.css">
        <script src="../codebase/dhtmlxcalendar.js"></script>

If you use dhtmlxCalendar as a part of 'dhtmlxSuite' package you need to include 2 files:

  • dhtmlx.js
  • dhtmlx.css
<link type="text/css" href="../codebase/dhtmlx.css">
<script src="../codebase/dhtmlx.js" type="text/javascript"></script>

Including source files from CDN

To include JS/CSS files of "dhtmlxSuite" package from CDN, you should set direct links to dhtmlx.js and dhtmlx.css files:

<link rel="stylesheet" href="" 
<script src="" 

By setting links in this way you will get the latest version of dhtmlxSuite. To get some particular version, just specify the number of the required version in the link, like this:

<link rel="stylesheet" href="" 
<script src="" 

Initializing Calendar

There are 6 ways to initialize dhtmlxCalendar on the page:

Initialization in a div

<div id="box" style="position:relative;height:250px;"></div>
var myCalendar = new dhtmlXCalendarObject("box");;

Attaching to an input

<input type="text" id="calendar">
<input type="text" id="calendar2">
var myCalendar = new dhtmlXCalendarObject(["calendar","calendar2"]);

Attaching to an input with an icon

<input type="text" id="calendar_input">
    <img id="calendar_icon" src="../common/calendar.gif" border="0">
var myCalendar = new dhtmlXCalendarObject(

Attaching to a custom icon

    <img id="calendar_icon" src="../common/calendar.gif" border="0">
<span id="date_here">&nbsp;</span>
var myCalendar = new dhtmlXCalendarObject({button: "calendar_icon"});

Using inside dhtmlxForm

formData = [
    {type:"calendar",label:"Start Date",skin:"dhx_skyblue", enableTime:true,
      dateFormat:"%Y-%m-%d %H:%i"},
    {type:"calendar", label:"End Date", skin:"dhx_skyblue", dateFormat:"%Y-%m-%d"}
myForm = new dhtmlXForm("myForm", formData);

Using inside dhtmlxToolbar

myToolbar = new dhtmlXToolbarObject("toolbarObj");
myToolbar.loadStruct("../common/dhxtoolbar_data.xml", function(){
  myToolbar.addInput("calendar", null, "12.06.2013", 90);
  myCalendar = new dhtmlXCalendarObject(myToolbar.getInput("calendar"));

Double calendar

<div id="box" style="position:relative;height:250px;"></div>
var myCalendar = new dhtmlXDoubleCalendar("box");

Back to top