CalendarXP.net Support Forum Index CalendarXP.net Support
Most forums here are private and invisible to public.
 
 FAQFAQ   SearchSearch   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

calulate days

 
Post new topic   Reply to topic    CalendarXP.net Support Forum Index -> PopCalendarXP Related
View previous topic :: View next topic  
Author Message
mdesign04



Joined: 15 May 2007
Posts: 11

PostPosted: Thu Jun 14, 2007 10:49 am    Post subject: calulate days Reply with quote

Hi,

I have a dropdown list with days, that when a depart date and a arrive date is selected populates the number of days of the selected two days.
It works fine if I go and chage the value on the arrivedate field.

Now what I want is that when I click the popup calendar button of the arrive date to pick a date, that this dropdown field gets also changed. I know there is the fAfterSelected function in the plug-in.js but I seem somehow to not get if work. Here is my funtion that currently makes it work by tiping the date manually in a text field.

Code:

function setDifference() {
   var x = document.getElementById('checkin1').value;
   var y = document.getElementById('checkout1').value;
   
   //assuming that the delimiter for dt time picker is a '/'.
   var arr1 = x.split('/');
   var arr2 = y.split('/');

   var dt1 = new Date();
   dt1.setFullYear(arr1[2], arr1[0], arr1[1]);
   var dt2 = new Date();
   dt2.setFullYear(arr2[2], arr2[0], arr2[1]);
   
   document.getElementById('staydays1').selectedIndex = (dt2.valueOf() - dt1.valueOf()) / (60 * 60 * 24 * 1000);
}


Where I would add this function in the plugin? Or how I get this function to work after the selection. I tried gfcontainer.setDifference() in the afterselected function, but it didn't work. Any suggestions?
Back to top
View user's profile Send private message
calendarxp
Site Admin


Joined: 30 Jan 2005
Posts: 409

PostPosted: Thu Jun 14, 2007 1:12 pm    Post subject: Reply with quote

When use scripts in plugin to access page objects, you need to prefix it with "gContainer.". In other words, you need to place the setDifference() in your own page (not in plugins.js) and then using the following code in plugins.js to call it:

function fAfterSelected(y,m,d,e) {
gContainer.setDifference();
}

Check this FAQ for more details:
http://www.calendarxp.net/forum/viewtopic.php?t=28&highlight=gcontainer

_________________
Copyright 2003-2011 Idemfactor Solutions, Inc. All rights reserved.
Back to top
View user's profile Send private message
mdesign04



Joined: 15 May 2007
Posts: 11

PostPosted: Thu Jun 14, 2007 6:26 pm    Post subject: Reply with quote

Hello, thanks I tried it before and added it now back. There is still nothing changing.

I also added now an extra alert window to test if it works at all.

Well the alert window pops up when I click the calendar button. It seems to execute the code before a date is picked so before the afterselect, can it be? I am not sure.
Back to top
View user's profile Send private message
calendarxp
Site Admin


Joined: 30 Jan 2005
Posts: 409

PostPosted: Thu Jun 14, 2007 9:46 pm    Post subject: Reply with quote

Please PM me with a test link, if possible.
_________________
Copyright 2003-2011 Idemfactor Solutions, Inc. All rights reserved.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    CalendarXP.net Support Forum Index -> PopCalendarXP Related All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum


Copyright 2003- Idemfactor Solutions, Inc. All rights reserved.
Powered by phpBB © 2001, 2005 phpBB Group