idrake
Member
Posts: 12
Registered: 3/10/2008
Location: usa
Member Is Offline
|
| posted on 3/20/2008 at 05:41 PM |
|
|
"calendar2.js is not a constructor" error
So I have calendar2.js, calendar.html and my htm page in the same directory, here's my code:
<p>Step One: click the calendar icon below to pick the date you want to fish...
<form name="schedule">
<input type="Text" name="input1" value="">
<a href="javascript:cal2.popup();"><img src="tigra_calendar/img/cal.gif" width="16" height="16" border="0" alt="Click Here to
Pick up the date"></a>
</form><script language="JavaScript">
<!-- // create calendar object(s) just after form tag closed
// specify form element as the only parameter (document.forms['formname'].elements['inputname']);
// note: you can have as many calendar objects as you need for your application
var call = new calendar2.js(document.forms['schedule'].elements['input1']);
cal2.year_scroll = true;
cal2.time_comp = false;
//-->
</script>
</p>
and firefox shows two errors:
calendar2.js is not a constructor, and
cal2 is not defined
I'm assuming having them all in the same directory means the path is right (maybe not?), but I have no idea what a constructor is or should be...
|
|
|
idrake
Member
Posts: 12
Registered: 3/10/2008
Location: usa
Member Is Offline
|
| posted on 3/20/2008 at 05:53 PM |
|
|
looking at some other posts I realize an error in the code was confusing var cal1 for var call--an error made because on my display the number one and
letter el are identical.
so, correcting the code to read var cal2 I now get these 2 errors:
calendar2.js is not a constructor
cal2 has no properties
Any help greatly appreciated as always, tks
|
|
|
tigra
Administrator
Posts: 1984
Registered: 6/17/2002
Location: US, CO
Member Is Offline
|
| posted on 3/20/2008 at 08:50 PM |
|
|
indeed calendar2.js is not a constructor, but the name of the file.
use it in the <script ..> in the header, like in this fragment from the sample:
<!-- American format mm/dd/yyyy -->
<script language="JavaScript" src="calendar2.js"></script>
now to create the calendar object you call 'calendar2' like in this fragment from the sample:
var cal5 = new calendar2(document.forms['tstest'].elements['input5']);
it worth noticing that you need to stick with the name of the variable. So if you define cal5 then that's what you use to set the properties and call
the calendar like in this fragments from the sample:
cal5.year_scroll = true;
cal5.time_comp = false;
and
<a href="javascript:cal5.popup();">
|
|
|
idrake
Member
Posts: 12
Registered: 3/10/2008
Location: usa
Member Is Offline
|
| posted on 3/20/2008 at 09:51 PM |
|
|
fantastic! my script had it like this: var cal2 = new calendar2.js(document.forms['schedule'].elements['input2']);
removed .js and it works.
but...
the browser window that pops up is too small for the calendar inside of it, and must be dragged open further to reveal the full calendar.
You're great with feedback, thanks!
Can we change the size of the popup window to fit the calendar?
|
|
|
tigra
Administrator
Posts: 1984
Registered: 6/17/2002
Location: US, CO
Member Is Offline
|
| posted on 3/21/2008 at 02:52 PM |
|
|
yes, you'll find the size of the window inside calendar2.js in window.open(...) call.
|
|
|
idrake
Member
Posts: 12
Registered: 3/10/2008
Location: usa
Member Is Offline
|
| posted on 3/22/2008 at 06:49 PM |
|
|
Well, the size of the popup window is only a problem in Firefox, where the calendar size is greater than the window size. It IE and Opera, at least,
the calendar resizes to fit the popup window. This isn't a big problem for Firefox users as the popup window itself can be dragged to fit the
calendar size by the user.
however, in calendar2.js, in window.open( I've tried changing the sizes of the window without success.
|
|
|