Catching id of manipulated input

Hi,

I’ve successfully setup the dhtmlxcalendar to input dates/times, which is working great.

I have a situation where I’d like to setup to use the calendar popup to work with an existing form that has 4 different date/times. The challenging issue is that the date and the hours and minutes of each of the 4 date/times is separate.

So when date1 is manipulated, the date1 as well as the date1hour and date1minute input boxes.

Is there a way to catch the ID of what is currently being manipulated so that the appropriate hour/minute fields can be updated?

I’d prefer to leave them as separate boxes as update the subsequent date/time fields (e.g. add a 4 hours for an end time (date/time2).

Please advise.

Hi
You can set ID to each calendar and use the “onChange” event of the form.

myForm.attachEvent("onChange", function (id, value){ alert("ID of calendar is "+id) });
But you can get this ID only if you choose any date.

that code didn’t work as expected. the id was actually the value of the calendar input rather than the id.

What I’d like to do is catch the date/time info and apply the date to one field and the time to another.

Is this possible to do with one function and 4 different sets of date/time?

Need to identify: do you need to something like below?

Choose date1 in Calendar1 => Use it in Calendar2 (i.e.disable all the days BEFORE this date)
And so on by the chain?

Am i right?

I’ll just do it a different way.

Need to revisit this.

Interestingly, the onClick and onChange seems to be programmed backwards.

Using the following code:

var myEvent = t.attachEvent(“onClick”, function (id, date){
alert("Date is changed to “+date+” id = "+id)
})

if I use onClick, the alert occurs once a date/time is selected. if I use onChange, the alert occurs as soon as I click on the field.

My real question though is it appears that only the DATE seems to be returned and it’s returned as the first variable, in this “id”.

Is there anyone to get the manipulated ID returned?

I want to do this:

once a value is selected, update the date/time values in 2 other date/time fields (once the first date is set, we want add time to the first value and then assign that value to the other 2 fields).

Is there a way possible?

Hi

onchange attached to form
onclick attached to calendar

actualy calendar does not know where it attached, in form, in div, in input, so it will not return ID becase it not have it.

if you need id in calendar’s onclick, you can do the following:

myForm.getCalendar(“start_date”)._id = “start_date”;
myForm.getCalendar(“start_date”).attachEvent(“onClick”, function (date){
// console.log(“onclick”, this._id, date);
});

I want to do this: …
use form’s onchange

Somehow, it has to know the id of the field that it just manipulated, it would seem. How else does it know where to put the date that you just clicked on?

I’m glad I’m not the only one noticing this issue.
When I change the value, I’d like to do different things on the page based on which input was updated.

I’ve found that I can kind of hack this using “onBeforeChange”. During the onBeforeChange event, you can still access the active input. Then you can use this.i[this._activeInp].input to access the actual input.

I’ve taken to using onBeforeChange and setting a timeout, but that’s really not a solid solution, since I can’t be certain that the change has completed before my code triggers. Just make sure you return true; at the end of your event, otherwise the change won’t happen.