| View previous topic :: View next topic | 
	
	
		| Author | Message | 
	
		| mdesign04 
 
 
 Joined: 15 May 2007
 Posts: 11
 
 
 | 
			
				|  Posted: Wed May 16, 2007 9:13 am    Post subject: populate 3 dropdown boxes |   |  
				| 
 |  
				| Hi I am somehow trying to get the example on this page http://www.calendarxp.net/tt_pop.shtml to work. Under Variety PopCalendarXP Demos, the example with the 3 dropdown menus. This works different as the one on the classic demo example. 
 Here the part of the code I have so far:
 
 
  	  | Code: |  	  | <form name="datesearch" method="post" action="bydate.php">
 
 <td width="24%"><?php
 // Get current Date for the default opening search
 if ($formbydate != '1')
 {
 $TodayDay = date("j");
 $TodayMonth = date("n");
 $TodayYear = date("Y");
 }
 ?><select name="searchDate_bymonth" class="selectionDatebox" onBlur="bydatemethod1()" onchange="if(self.gfPop)gfPop.updateHidden(this)">
 <OPTION value="1" <?php if ($TodayMonth == '1' || $bymonth == '1') { echo  "selected"; } ?>>January</OPTION>
 <OPTION value="2" <?php if ($TodayMonth == '2' || $bymonth == '2') { echo  "selected"; } ?>>February</OPTION>
 <OPTION value="3" <?php if ($TodayMonth == '3' || $bymonth == '3') { echo  "selected"; } ?>>March</OPTION>
 <OPTION value="4" <?php if ($TodayMonth == '4' || $bymonth == '4') { echo  "selected"; } ?>>April</OPTION>
 <OPTION value="5" <?php if ($TodayMonth == '5' || $bymonth == '5') { echo  "selected"; } ?>>May</OPTION>
 <OPTION value="6" <?php if ($TodayMonth == '6' || $bymonth == '6') { echo  "selected"; } ?>>June</OPTION>
 <OPTION value="7" <?php if ($TodayMonth == '7' || $bymonth == '7') { echo  "selected"; } ?>>July</OPTION>
 <OPTION value="8" <?php if ($TodayMonth == '8' || $bymonth == '8') { echo  "selected"; } ?>>August</OPTION>
 <OPTION value="9" <?php if ($TodayMonth == '9' || $bymonth == '9') { echo  "selected"; } ?>>September</OPTION>
 <OPTION value="10" <?php if ($TodayMonth == '10' || $bymonth == '10') { echo  "selected"; } ?>>October</OPTION>
 <OPTION value="11" <?php if ($TodayMonth == '11' || $bymonth == '11') { echo  "selected"; } ?>>November</OPTION>
 <OPTION value="12" <?php if ($TodayMonth == '12' || $bymonth == '12') { echo  "selected"; } ?>>December</OPTION>
 </select></td>
 <td width="11%"><select name="searchDate_byday" class="selectionDatebox" onBlur="bydatemethod1()" onchange="if(self.gfPop)gfPop.updateHidden(this)">
 <?php
 for ($i = 1; $i <= '31'; $i++)
 {
 echo "<OPTION value=\"$i\"";
 if ($i == $TodayDay || $i == $byday) { echo "selected"; }
 echo ">$i</OPTION>";
 </select>
 </td>
 <td width="18%"><select name="searchDate_byyear" class="selectionDatebox" onBlur="bydatemethod1()" onchange="if(self.gfPop)gfPop.updateHidden(this)"><?php
 for ($i = 2007; $i <= '2012'; $i++)
 {
 echo "<OPTION value=\"$i\"";
 if ($i == $TodayYear || $i == $byyear) { echo "selected"; }
 echo ">$i</OPTION>";
 }
 ?></select>
 </td>
 
 And here the Calender trigger link
 
 <td width="42%"><span class="popcal"><img src="images/calendar/cal.gif" width="16" height="16" border="0" align="absmiddle" onclick="if(this.blur)this.blur();var fm=document.datesearch;if(self.gfPop)gfPop.fPopCalendar(fm.searchDate,fm.searchDate_bymonth,fm.searchDate_byday,fm.SearchDate_byyear);" onmouseover="this.style.cursor='hand'; return;" href="javascript:void(0)"></span><input name="searchDate" type="hidden" value=""></td>
 | 
 
 The iframe:
 
  	  | Code: |  	  | <iframe width=178 height=183 name="gToday:normal:agenda.js" id="gToday:normal:agenda.js"
 src="calendar/ipopeng.htm" scrolling="no" frameborder="0"
 style="visibility:visible; z-index:999; position:absolute; top:-500px;">
 <LAYER name="gToday:normal:agenda.js" src="calendar/npopeng.htm:agenda.js" background="calendar/npopeng.htm"></LAYER>
 </iframe>
 | 
 
 And the plugin.js contains:
 
  	  | Code: |  	  | function updateHidden(dc) {
 var prefix=dc.name.split("_")[0];
 var els=dc.form.elements;
 els[prefix].value=fFormatInput(els[prefix+"_byyear"].options[els[prefix+"_byyear"].selectedIndex].value,els[prefix+"_bymonth"].options[els[prefix+"_bymonth"].selectedIndex].value,els[prefix+"_byday"].options[els[prefix+"_byday"].selectedIndex].value);
 }
 function fAfterSelected(y,m,d,e) {
 var prefix=gdCtrl.name;
 var formRef=gdCtrl.form;
 formRef.elements[prefix+"_byday"].options.selectedIndex=d;
 formRef.elements[prefix+"_bymonth"].options.selectedIndex=m;
 var _yc=formRef.elements[prefix+"_byyear"];
 _yc.options.selectedIndex=y-_yc.options[1].value+1;
 }
 
 | 
 
 What I am doing wrong? I get the error message:
 refering to the ipopeng.htm file 	  | Code: |  	  | gcbYear.options.0.value is null or not an object | 
 |  | 
	
		| Back to top |  | 
	
		|  | 
	
		| calendarxp Site Admin
 
 
 Joined: 30 Jan 2005
 Posts: 409
 
 
 | 
			
				|  Posted: Wed May 16, 2007 12:54 pm    Post subject: |   |  
				| 
 |  
				| Could you please use Firefox to view the same page and telling us the error message in the "tools/error console"? 
 The error message in IE is not accurate.
 _________________
 Copyright 2003-2011 Idemfactor Solutions, Inc. All rights reserved.
 |  | 
	
		| Back to top |  | 
	
		|  | 
	
		| mdesign04 
 
 
 Joined: 15 May 2007
 Posts: 11
 
 
 | 
			
				|  Posted: Wed May 16, 2007 5:58 pm    Post subject: |   |  
				| 
 |  
				| I just now open it in Firefox, the trigger doesn't work there. After clicking it doesn't do nothing and I also don't get a error message. |  | 
	
		| Back to top |  | 
	
		|  | 
	
		| calendarxp Site Admin
 
 
 Joined: 30 Jan 2005
 Posts: 409
 
 
 | 
			
				|  Posted: Wed May 16, 2007 10:49 pm    Post subject: |   |  
				| 
 |  
				| Could you please provide us a link to test? _________________
 Copyright 2003-2011 Idemfactor Solutions, Inc. All rights reserved.
 |  | 
	
		| Back to top |  | 
	
		|  | 
	
		| mdesign04 
 
 
 Joined: 15 May 2007
 Posts: 11
 
 
 | 
			
				|  Posted: Thu May 17, 2007 7:41 am    Post subject: |   |  
				| 
 |  
				| Hi, I sent you the link in a private message as the site is not public yet and you have to login.
 |  | 
	
		| Back to top |  | 
	
		|  | 
	
		| calendarxp Site Admin
 
 
 Joined: 30 Jan 2005
 Posts: 409
 
 
 | 
			
				|  Posted: Thu May 17, 2007 1:01 pm    Post subject: |   |  
				| 
 |  
				| Please add the following code to the end of your plugins.js: 
  	  | Code: |  	  | function fPopCombo(dayc,monc,yearc,dc) { _dc=dayc; _mc=monc; _yc=yearc;
 dc.value=fFormatInput(_yc.value,_mc.value,_dc.value);
 fPopCalendar(dc, null, null, yearc);
 }
 | 
 Then change the onclick event of your button tag to:
 
  	  | Code: |  	  | onclick="if(this.blur)this.blur();var fm=document.datesearch;if(self.gfPop)gfPop.fPopCalendar(fm.searchDate_byday,fm.searchDate_bymonth,fm.SearchDate_byyear,fm.searchDate);" | 
 _________________
 Copyright 2003-2011 Idemfactor Solutions, Inc. All rights reserved.
 |  | 
	
		| Back to top |  | 
	
		|  | 
	
		| mdesign04 
 
 
 Joined: 15 May 2007
 Posts: 11
 
 
 | 
			
				|  Posted: Thu May 17, 2007 6:37 pm    Post subject: |   |  
				| 
 |  
				| it is still doing the same. 
 I notice that the function bellow has fPopCalender, should it not be fPopCombo as function? I tried it and get a different error message then. so I put it back to have the code you supported.
 
 _yc.value is not or not an object.
 
 
  	  | Code: |  	  | onclick="if(this.blur)this.blur();var fm=document.datesearch;if(self.gfPop)gfPop.fPopCalendar(fm.searchDate_byday,fm.searchDate_bymonth,fm.SearchDate_byyear,fm.searchDate);"
 | 
 
 sorry for the inconvenience, but still nothing on both browsers and I don't see right now why it is not doing it. Everything seems to be fine.[/code]
 |  | 
	
		| Back to top |  | 
	
		|  | 
	
		| calendarxp Site Admin
 
 
 Joined: 30 Jan 2005
 Posts: 409
 
 
 | 
			
				|  Posted: Fri May 18, 2007 2:06 am    Post subject: |   |  
				| 
 |  
				| Sorry, my mistake - you're right, fPopCombo() should be used in place of fPopCalendar(): 
 
  	  | Code: |  	  | onclick="if(this.blur)this.blur();var fm=document.datesearch;if(self.gfPop)gfPop.fPopCombo(fm.searchDate_byday,fm.searchDate_bymonth,fm.SearchDate_byyear,fm.searchDate);" | 
 _________________
 Copyright 2003-2011 Idemfactor Solutions, Inc. All rights reserved.
 |  | 
	
		| Back to top |  | 
	
		|  | 
	
		| mdesign04 
 
 
 Joined: 15 May 2007
 Posts: 11
 
 
 | 
			
				|  Posted: Fri May 18, 2007 6:50 am    Post subject: |   |  
				| 
 |  
				| ok changed it then I get this error in IE, 
 _yc.value is not or not an object.
 
 like I wrote in my last post. I figured that out, the searchDate_byyear had a capital S at the beginning like SearchDate_byyear, after changing this it works almost, the calendar pops up, I am abble to pick a date and the dropdowns change.
 
 Only one error left, if I click for instance 22th May 2007 or any other date, it adds always + 1 month, so that the dropdown change to 22th June 2007.
 Then you pick a different date and it adds another month to it. So 23rd July 2007.
 |  | 
	
		| Back to top |  | 
	
		|  | 
	
		| mdesign04 
 
 
 Joined: 15 May 2007
 Posts: 11
 
 
 | 
			
				|  Posted: Fri May 18, 2007 11:56 am    Post subject: |   |  
				| 
 |  
				| Hi, 
 I got it finally to work,
 
 I saw now the problem myself. first at all the hidden value text field needs a dummy date to populate the calendar back as this was also not working, so I entered here a dummy date and this was working.
 
 the problem with the calendar was due to the dropdown boxws, the month and day box didn't have a 0 value, they started with 1-31 and 1-12. After adding here a 0 value at the beginning, the problem was gone.
 
 Many thanks to pointing me on the right direction to solve the problem.
 |  | 
	
		| Back to top |  | 
	
		|  | 
	
		| calendarxp Site Admin
 
 
 Joined: 30 Jan 2005
 Posts: 409
 
 
 | 
			
				|  Posted: Fri May 18, 2007 12:36 pm    Post subject: |   |  
				| 
 |  
				| Actually, you may modify the fAfterSelected() if you don't want to use a 0 value in options. e.g. 
  	  | Code: |  	  | function fAfterSelected(y,m,d,e) {
 var prefix=gdCtrl.name, formRef=gdCtrl.form;
 var _yc=formRef.elements[prefix+"_year"], _mc=formRef.elements[prefix+"_mon"], _dc=formRef.elements[prefix+"_day"];
 _dc.options.selectedIndex=d-_dc.options[1].value+1;
 _mc.options.selectedIndex=m-_mc.options[1].value+1;
 _yc.options.selectedIndex=y-_yc.options[1].value+1;
 }
 
 | 
 Anyway, good to know you get it working.
 _________________
 Copyright 2003-2011 Idemfactor Solutions, Inc. All rights reserved.
 |  | 
	
		| Back to top |  | 
	
		|  | 
	
		| mdesign04 
 
 
 Joined: 15 May 2007
 Posts: 11
 
 
 | 
			
				|  Posted: Fri May 18, 2007 4:58 pm    Post subject: |   |  
				| 
 |  
				| Sounds good as I don't necessary need the null values. 
 Thank you very much for all.
 |  | 
	
		| Back to top |  | 
	
		|  | 
	
		|  |