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 

Problems with using an image as the button

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



Joined: 23 Sep 2006
Posts: 4

PostPosted: Sat Sep 23, 2006 2:37 pm    Post subject: Problems with using an image as the button Reply with quote

Hi

This has been bugging me for ages... i've read through your FAQs but not found a solution so I must be doing something wrong.

I'm trying to use a calendar image instead of a form button along with the data drop down - here's my code:

Code:
<a href="javascript:void(0)"
onClick="if(this.blur)this.blur();var fm=this.form;if(self.gfPop)gfPop.fPopCalendar(document.Search.arrDate,[[<%=Year(iCalendarYearsStart)%>,<%=Month(iCalendarYearsStart)%>,<%=Day(iCalendarYearsStart)%>],[<%=Year(iCalendarYearsEnd)%>,<%=Month(iCalendarYearsEnd)%>,<%=Day(iCalendarYearsEnd)%>]],fm.arrDate_year);">
<img src="images/btnLogin.gif" alt="popup" name="popcal2" width="34" height="22" border="0" align="absmiddle" id="popcal2">
</a>


I adapted this from the following code (which works fine):

Code:
<input name="popcal2" onMouseOver="this.style.cursor='hand'"
onClick="if(this.blur)this.blur();var fm=this.form;if(self.gfPop)gfPop.fPopCalendar(document.Search.arrDate,[[<%=Year(iCalendarYearsStart)%>,<%=Month(iCalendarYearsStart)%>,<%=Day(iCalendarYearsStart)%>],[<%=Year(iCalendarYearsEnd)%>,<%=Month(iCalendarYearsEnd)%>,<%=Day(iCalendarYearsEnd)%>]],fm.arrDate_year);" type="button" value="..." class="CalendarButton"  />


However, then I run the code with the image button I get the following Javascript error:

Error: 'arrDate_year' is null pr not an object

Any ideas?
Back to top
View user's profile Send private message
calendarxp
Site Admin


Joined: 30 Jan 2005
Posts: 409

PostPosted: Sat Sep 23, 2006 2:48 pm    Post subject: Reply with quote

Yes, there is one thing incorrect - the this.form only works for form elements, i.e. <input> tags. In your case, you moved the onclick handler to <a> tag, which is not a form element and doesn't support this.form. To fix it you need to reference your form via the whole name, e.g. document.formName

Here is a modified code snippet that should work for you, assuming the enclosing form name is "myFormName":
Code:
<a href="javascript:void(0)"
   onClick="if(this.blur)this.blur();var fm=document.myFormName;if(self.gfPop)gfPop.fPopCalendar(document.Search.arrDate,[[<%=Year(iCalendarYearsStart)%>,<%=Month(iCalendarYearsStart)%>,<%=Day(iCalendarYearsStart)%>],[<%=Year(iCalendarYearsEnd)%>,<%=Month(iCalendarYearsEnd)%>,<%=Day(iCalendarYearsEnd)%>]],fm.arrDate_year);">
   <img src="images/btnLogin.gif" alt="popup" name="popcal2" width="34" height="22" border="0" align="absmiddle" id="popcal2">
</a>

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


Joined: 30 Jan 2005
Posts: 409

PostPosted: Sat Sep 23, 2006 3:00 pm    Post subject: Reply with quote

Also, one more thing to remind is that I noticed that you use "popcal2" as the name of the image - which is something you should be careful as the script engine needs to identify where to popup the calendar by using a specific naming convention.

Details may be found at the following FAQ:
http://www.calendarxp.net/forum/viewtopic.php?t=76&highlight=name+popcal

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



Joined: 23 Sep 2006
Posts: 4

PostPosted: Sun Sep 24, 2006 4:39 pm    Post subject: Reply with quote

Just wanted to say thanks - this now works Smile
Back to top
View user's profile Send private message
sfakman



Joined: 23 Sep 2006
Posts: 4

PostPosted: Sun Sep 24, 2006 4:47 pm    Post subject: Reply with quote

Oh one other thing - I hope you can help me with (I'm not an expert at this)...

I wanted to do the whole date range thing, like you do in the Dynamic Date range demo (http://www.calendarxp.net/tt_pop.shtml) but I can't quite suss it out using the drop downs.

My Start date code is this:

Code:

<a href="javascript:void(0)" onClick="if(this.blur)this.blur();var fm=document.Search;if(self.gfPop)gfPop.fPopCalendar(document.Search.arrDate,[[<%=Year(iCalendarYearsStart)%>,<%=Month(iCalendarYearsStart)%>,<%=Day(iCalendarYearsStart)%>],[<%=Year(iCalendarYearsEnd)%>,<%=Month(iCalendarYearsEnd)%>,<%=Day(iCalendarYearsEnd)%>]],fm.arrDate_year);"><img src="images/cal.gif" alt="Calendar" name="popcal" width="34" height="21" border="0" align="absmiddle" id="popcal"></a>


And my end date code is this:

Code:

<a href="javascript:void(0)" onClick="if(this.blur)this.blur();var fm=document.Search;if(self.gfPop)gfPop.fPopCalendar(document.Search.deptDate,[[<%=Year(iCalendarYearsStart)%>,<%=Month(iCalendarYearsStart)%>,<%=Day(iCalendarYearsStart)%>],[<%=Year(iCalendarYearsEnd)%>,<%=Month(iCalendarYearsEnd)%>,<%=Day(iCalendarYearsEnd)%>]],fm.deptDate_year);"><img src="images/cal.gif" alt="Calendar" name="popcal2" width="34" height="21" border="0" align="absmiddle" id="popcal2"></a>   


How can I enable it so that you cant start after the end-date or end before the start-date?

Thanks again
Back to top
View user's profile Send private message
calendarxp
Site Admin


Joined: 30 Jan 2005
Posts: 409

PostPosted: Sun Sep 24, 2006 7:45 pm    Post subject: Reply with quote

We do have an FAQ about how to restrict the end date according to start date - http://www.calendarxp.net/forum/viewtopic.php?t=130

By the way, please start a new thread if you would like to further discuss the date range as the current topic will be considered closed if the solution works. Thanks.

_________________
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