skizzly
Newbie
Posts: 1
Registered: 10/21/2004
Member Is Offline
|
| posted on 10/25/2004 at 05:47 PM |
|
|
multiple calenders 1 form
hi all,
have downloaded the free version of the calendar. I have 1 form but wish to use 3 seperate calendars . What is happening is that only 1 field is being
referenced in stead of the individual input fields.
I click calander 1 and it refernces input field 1, but calander 2 and 3 reference the same input field.
I have changed the var name and ensured the correct input fields are referenced. Has anyone got a idea of what is going on?
|
|
|
dazman
Junior Member
Posts: 3
Registered: 2/2/2005
Member Is Offline
|
| posted on 2/2/2005 at 03:02 PM |
|
|
Found the point in code
Hey. I have the same problem too. The problem is in the javascript at the top of calendar.html
These two lines of code:
var num_id = (re_id.exec(String(window.location))
? new Number(RegExp.$1) : 0);
var obj_caller = (window.opener ? window.opener.calendars[num_id] : null);
return the last created calendar. You can prove this by adding the line alert(obj_caller.target.name); after these.
I am not the best coder so I thought this may help someone? I assume that window.opener is failing and it's using the default
(window.opener.calendars[num_id] ) which is the last calendar created.
|
|
|
dazman
Junior Member
Posts: 3
Registered: 2/2/2005
Member Is Offline
|
| posted on 2/2/2005 at 03:44 PM |
|
|
Really found the point in code
After a bit of digging, I noticed that the global calendars array in the .js file isn't being updated so it's overwriting the previous
calendar.
Maybe it's the way I (we) set up the calendars?
Shouldn't someone from Soft Complex be looking into this? Seems odd to release buggy code.
Darren
|
|
|
dazman
Junior Member
Posts: 3
Registered: 2/2/2005
Member Is Offline
|
| posted on 2/2/2005 at 04:20 PM |
|
|
A solution
Ok, I started fixing the buggy global calendar stuff and then wondered why. I simply want to set the value of a text field, I don't care which
instance of the calendar is showing (for memory saving reasons maybe soft complex should look into this).
Solution:
Change the name of the calendar window to that of the ID of the text field you want to change. Then access the element id via that value.
What that means is...
Step 1.
in your .js code change:
var obj_calwindow = window.open(
'calendar.html?datetime=' + this.dt_current.valueOf()+ '&id=' + this.id,
'calendar', 'width=200,height='+(this.time_comp ? 215 : 190)+
',status=no,resizable=no,top=200,left=200,dependent=yes,alwaysRaised=yes'
);
To be:
var obj_calwindow = window.open(
'calendar.html?datetime=' + this.dt_current.valueOf()+ '&id=' + this.id,
this.target.name, 'width=200,height='+(this.time_comp ? 215 : 190)+
',status=no,resizable=no,top=200,left=200,dependent=yes,alwaysRaised=yes'
);
Step 2.
In your calendar.html code add the line:
var elToUpdate = window.parent.opener.document.getElementById(window.name);
directly above the line (to keep it simple)
var obj_caller = (window.opener ? window.opener.calendars[num_id] : null);
Step 3:
In your calendar.html code change the line(s):
obj_caller.target.value = (document.cal
? obj_caller.gen_tsmp(dt_datetime)
: obj_caller.gen_date(dt_datetime)
);
to be
elToUpdate.value = (document.cal
? obj_caller.gen_tsmp(dt_datetime)
: obj_caller.gen_date(dt_datetime)
);
That's it. Your calendar will now reference the correct text field. I hope I didn't change too much and this sample code looks something
like the original.
Enjoy.
|
|
|
rdygert
Junior Member
Posts: 2
Registered: 2/9/2005
Member Is Offline
|
| posted on 2/9/2005 at 09:02 PM |
|
|
dazman,
I have a form with about 8 date entry fields on it. I changed the code as you indicated but at every point I enter a date on a given form using the
calendar, only the last date value on the form gets populated. The date is the correct value that I picked, it just populates the wrong text box.
Unless I didn't copy your code correctly, do you have any idea why it's not working for me?
Thanks,
rdygert
|
|
|
rdygert
Junior Member
Posts: 2
Registered: 2/9/2005
Member Is Offline
|
| posted on 2/10/2005 at 02:09 PM |
|
|
All,
I found the problem. Thanks. I neglected to write in all the new number calendar instances, ie. cal2, cal3, cal4 etc.
|
|
|