Attach single calendar to form

Hello all,
I was wondering if someone could help me on how to attach a single calendar to an input on the form. I was reading the other topic on how to attach a double, but it wasnt working. I kept getting an error in my browser saying that “object missing in calendar.js”.

<a onclick="filter()">click me</a>

The code

var dhxWins, w1, dhxList;
function filter() {
    var formData = [
        {type: "input", id: "datefrom", label: "Select a date"},
        {type: "button", name: "submit", value: "Filter"}
    dhxWins = new dhtmlXWindows();
    x = (document.body.clientWidth/2)-(400/2);
    y = (document.body.clientHeight/2)-(520/2);
    w1 = dhxWins.createWindow("w1", x, y, 400, 520);
    w1.setText("Filter Criteria");
    dhxList = w1.attachForm(formData);

Thanks for any help.


Please see attached demo. (57.1 KB)

I appoligize for this,
but can anyone post the coding. Im in afghanistan and i cant download it because of our network administrators. Thanks





The above example works only for one html input element. When a second html input element is added to the form.The calendar works only for one input element. The one which was activated as first.


var form, myCalendar;
function doOnLoad() {
		var formData = [
			{type: "input", name: "calendar1", label: "Date2"},
			{type: "input", name: "calendar", label: "Date"},
			{type: "button", name: "btn", value: "Submit"}
		form = new dhtmlXForm("listObj", formData);
		dhtmlXForm.prototype.items.input.showCalendar = function(item) {
			var inp = item.childNodes[0].childNodes[1].childNodes[0];
			inp.onclick = function(e){
				e = e||event;
				e.cancelBubble = true;
				e.returnValue = false;
				if (!myCalendar) {
					myCalendar = new dhtmlXCalendarObject(this, true);;

				return false;
		form.doWithItem("calendar", "showCalendar");
		form.doWithItem("calendar1", "showCalendar");

I have in my form multiple input element where I need to add a calendar. (Single calendar)

then you need separate intances

var myCalendar = {};

if (!myCalendar[this._idd]) {
myCalendar[this._idd] = new dhtmlXCalendarObject(…);

I just removed the if statement and callendar get recreated. This works also.

[code]inp.onclick = function(e){
e = e||event;
e.cancelBubble = true;
e.returnValue = false;
//if (!myCalendar) {
myCalendar = new dhtmlXCalendarObject(this, true);

				return false;

Yes, but it not good create every time new instance.

Why ?