Board Logo

Cal1 sets Cal2?s beginning date
kzimme - 12/12/2003 at 09:19 PM

I have 2 calendars on one web page. I would like to have the date selected in Calendar 1 set the start date for Calendar 2 ? How can I do this?


CFD - 12/17/2003 at 07:36 AM

Write me a letter, and I send for you solution of this problem.


viggo - 12/25/2003 at 11:01 PM

Quote:
Originally posted by CFD
Write me a letter, and I send for you solution of this problem.


I need this answer also?


toons43 - 6/2/2008 at 02:58 PM

Hi,

I'd like a solution for this too

Thanks in advance


tigra - 6/3/2008 at 09:45 AM

Additional coding is required to implement this in free version of the script. This functionality requires the event handling that free version doesn't currently support.

Date range selection can be achieved with PRO version of the script. See demo at:
http://www.softcomplex.com/products/tigra_calendar_pro/demo/modal_reservation.html


spiffyjwc - 6/7/2008 at 12:06 AM

I've fiddled with the code myself to get this functionality, and I think i've come up with a solution!
You've got to add the following functions to the javascript file:
I'd rather have overloaded the original functions, but seeing as though there isn't overloading in JS.... we're basically going to add two new functions. to add a couple lines of code:
We're creating a new "target" in the first function by modifying/adding these lines:

Code:

this.target = new_target;
this.oldtarget=obj_target;

and then we've got to switch it appropriately in the popup function:
Code:

if ((this.oldtarget.value) && !(this.target.value))
this.dt_selected = this.dt_current = this.prs_tsmp(this.oldtarget.value);
else
this.dt_selected = this.dt_current = this.prs_tsmp(this.target.value);


so our two new functions are:
Code:

function calendarLastDate(obj_target, new_target) {

// assigning methods
this.gen_date = cal_gen_date2;
this.gen_time = cal_gen_time2;
this.gen_tsmp = cal_gen_tsmp2;
this.prs_date = cal_prs_date2;
this.prs_time = cal_prs_time2;
this.prs_tsmp = cal_prs_tsmp2;
this.popup = cal_popupNew;

// validate input parameters
if (!obj_target)
return cal_error("Error calling the calendar: no target control specified");
if (obj_target.value == null)
return cal_error("Error calling the calendar: parameter specified is not valid target control");
this.target = new_target;
this.oldtarget=obj_target;
this.time_comp = BUL_TIMECOMPONENT;
this.year_scroll = BUL_YEARSCROLL;

// register in global collections
this.id = calendars.length;
calendars[this.id] = this;
}
function cal_popupNew (str_datetime) {
if (str_datetime)
this.dt_current = this.prs_tsmp(str_datetime);
else{
if ((this.oldtarget.value) && !(this.target.value))
this.dt_selected = this.dt_current = this.prs_tsmp(this.oldtarget.value);
else
this.dt_selected = this.dt_current = this.prs_tsmp(this.target.value);
}

if (!this.dt_current) return;

var obj_calwindow = window.open(
'calendar.html?id=' + this.id + '&s=' + this.dt_selected.valueOf() + '&c=' + this.dt_current.valueOf(),
'Calendar', 'width=200,height=' + (this.time_comp ? 215 : 190) +
',status=no,resizable=no,top=200,left=200,dependent=yes,alwaysRaised=yes'
);
obj_calwindow.opener = window;
obj_calwindow.focus();
}


Now use the following to declare your variables after your form:
Code:

var calx = new calendarLastDate(document.forms['formName'].elements['firstCalendar'],document.forms['formName'].elements['secondCalendar']);


where "firstCalendar" will contain the date that you want to replicated into "secondCalendar." In the event that secondCalendar is clicked first, this should return the current day.
Hope i got it right - I was certainly looking into this feature as well!

I did this with the "calendar2.js" version, and it appears to work well!


paulg - 9/20/2008 at 09:55 AM

Cool..... It works. Thank you spiffyjwc. I have been trying to figure out how to do this quite some time now


Softcomplex: http://www.softcomplex.com/
Back to forum: http://www.softcomplex.com/forum/