DHTMLX Docs & Samples Explorer

Initialization of dhtmlxCalendar

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 to your html file the related CSS and JS files.
  3. Call an object constructor.

Included files (steps 1, 2)

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

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

  • dhtmlxcalendar_dhx_skyblue.css.js
  • dhtmlxcalendar.js
  • dhtmlxcalendar.css

    <!DOCTYPE html>
    <html>
      <head>
          <link rel="stylesheet" type="text/css" href="../codebase/dhtmlxcalendar.css">
          <script src="../codebase/skins/dhtmlxcalendar_dhx_skyblue.css.js"></script>
          <script src="../codebase/dhtmlxcalendar.js"></script>
      </head>
     <body>
     ...
     </body>
    </html>

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

  • dhtmlx.js
  • dhtmlx.css

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

Initialization (step 3)

There 2 ways of dhtmlxCalendar initialization:

  1. Common initialization (as an individual object) See example

    myCalendar = new dhtmlXCalendarObject("box");
    myCalendar.show();

    where box is an HTML container

  2. Calendar as date input field

    • As individual control See example

      var myCalendar = new dhtmlXCalendarObject(["calendar","calendar2","calendar3"]);

      where calendar, calendar2, calendar3 are HTML <INPUT> elements

    • As form's control See example

      formData = [
      	{type: "calendar", dateFormat: "%Y-%m-%d %H:%i", value: "2011-06-13 11:35", name: "start_date", label: "Start Date", skin: "dhx_skyblue", readonly: true, enableTime: true, calendarPosition: "right"},
      	{type: "calendar", name: "end_date", label: "End Date", value: "2011-02-10", dateFormat: "%Y-%m-%d", calendarPosition: "right"}]
      ];
      myForm = new dhtmlXForm("formContainer", formData);