Calendar attachobject

Hi,

I have two text boxes on a screen. I initialize the calendar with the first text box and then in the onclick event of the second text box , I use the attachobject method of the calendar to attach the calendar to the second text box. How ever this throws the following error:

Error: this.i[a].addEventListener is not a function
Source File: 125.17.102.11/cdss_pg/…/dhtmlxcalendar.js
Line: 1341

The problem is replicated in the following example:
125.17.102.11/cdss_pg/default.aspx

How to make the same calendar work with several input text boxes. Please help.

Regards,
Sravanthi Sontha

When initializing the calendar, you can attach it to several inputs. For example :

var calendar = new dhtmlXCalendarObject(['input1', 'input2']);

Hi,

My textboxes are dynamically created, hence I would not be able to do what you have suggested. How to make it work with attachObject?

Thanks ,
Sravanthi Sontha

I have the same problem with version 3.0

Previously, I used v2.1 and it works fine (e.g. 1 calendar for multiple input without the need to attach object ).

I also have my input field dynamically generated.

Please help

Hi,

Any help would be appreciated.

Thanks
Sravanthi

Hi,

There is setParent method that attaches calendar to another div. However, it won’t apply features that are actual when you attaches calendar to several inputs.

dhtmlxCalendar/samples/01_init_and_usage/04_change_parent.html

Also you may use setPosition method which displays calendar in a certain top and left position. Here are the post with the latest libraries attached:
viewtopic.php?f=7&t=20171&p=64207#p64207
Please use them

Hi ,

I have used the set parent and it is working, but as you said it won’t apply features that are actual when you attaches calendar to several inputs. I need to access the date returned and put it back into my text back. How can I access its parent? I have tried one of your suggestions in your previous post
var id = (typeof calendar.contId != ‘string’?calendar.contId.id:calendar.contId);
But it is throwing an error - " contid is undefined "
Is there a way we can make the attachobject function work?

Thanks ,
Sravanthi

Hi,

Calendar doesn’t support attachObject method. You can either attach calendar to several inputs or create a simple calendar with div as a parent container. In the latter case, you may use setPosition method to show calendar in different positions.

Hi,

How is it possible to attach a calendar to several inputs when the inputs are dynamically loaded?

Thanks
Sravanthi

If you want to use automatic attaching to inputs, you may unload the existent calendar and then create it for another set of inputs:

myCalendar = new dhtmlXCalendarObject([“input1”]);
/to add more inputs/
myCalendar.unload();
myCalendar = new dhtmlXCalendarObject([“input1”,“input2”,“input3”]);

Hello,

calendar have functionality to be attached to/detached from inputs on the fly.

try this:

myCalendar.attachObj(obj)

obj param should be object, not id or other text.

like this:

var newInp = document.createElement("INPUT"); newInp.type = "text"; document.body.appendChild(newInp); myCalendar.attachObj(newInp);