By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,106 Members | 2,679 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,106 IT Pros & Developers. It's quick & easy.

javascript runtime error

P: 1
the error is "runtime error object expected" here is the code.............................................. .........................................


[HTML] <script language="javascript" src="../Scripts/calender.js"></script>
</HEAD>
<body bgColor="white" MS_POSITIONING="GridLayout">
<form id="Form1" style="LEFT: 0px; POSITION: absolute; TOP: 0px" method="post" runat="server">
<!--<table width="100%" style="LEFT: 0px; POSITION: absolute; TOP: 0px">-->
<table width="70%" align="center">
<tbody>
<tr>
<td vAlign="top"><IMG id="Img1" src="Images/AMP_Banner.jpg" align="left" runat="server"></td>
</tr>
<tr>
<td align="right"><asp:hyperlink id="HyperLink2" runat="server" NavigateUrl="Logout.aspx" CssClass="hLink">Log Off</asp:hyperlink></td>
</tr>
<tr>
<td>
<table width="100%" align="center" border="1">
<TR>
<TD><asp:label id="lbl1" runat="server" CssClass="label1">Associate ID:</asp:label></TD>
<TD><asp:label id="lblAssociateId" runat="server" CssClass="label"></asp:label></TD>
<TD><asp:label id="lbl2" runat="server" CssClass="label1">Associate Name</asp:label></TD>
<TD><asp:label id="lblAssociateName" runat="server" CssClass="label"></asp:label></TD>
<TD><asp:label id="lbl3" runat="server" CssClass="label1">Email ID</asp:label></TD>
<TD><asp:label id="lblAssEmail" runat="server" CssClass="hlink">Label</asp:label></TD>
</TR>
<TR>
<TD><asp:label id="lbl4" runat="server" CssClass="label1">Client</asp:label></TD>
<TD><asp:label id="lblClient" runat="server" CssClass="label">Label</asp:label></TD>
<TD><asp:label id="lbl5" runat="server" CssClass="label1">Process</asp:label></TD>
<TD><asp:label id="lblProcess" runat="server" CssClass="label">Label</asp:label></TD>
<TD><asp:label id="lbl6" runat="server" CssClass="label1">SubProcess</asp:label></TD>
<TD><asp:label id="lblSubProcess" runat="server" CssClass="label">Label</asp:label></TD>
</TR>
<TR class="label1">
<TD><asp:label id="Label14" runat="server" CssClass="label1">Location</asp:label></TD>
<TD><asp:label id="lblLoc" runat="server" CssClass="label">Label</asp:label></TD>
<TD><asp:label id="lblAssName" runat="server" CssClass="label1">RM_Id</asp:label></TD>
<TD><asp:label id="lblRmId" runat="server" CssClass="label">Label</asp:label></TD>
<TD><asp:label id="Label18" runat="server" CssClass="label1">RM Email ID</asp:label></TD>
<TD><asp:label id="lblRmEmail" runat="server" CssClass="hLink">Label</asp:label></TD>
</TR>
</table>
</td>
</tr>
<tr>
<td>
<TABLE id="Table2" width="100%" border="1">
<TR>
<TD><asp:label id="Label6" runat="server" CssClass="label1">Select the Associate</asp:label></TD>
<TD><asp:dropdownlist id="ddlassociate" runat="server" CssClass="DataCombo" AutoPostBack="True" Width="208px"></asp:dropdownlist></TD>
</TR>
<TR>
<TD><asp:label id="Label5" runat="server" CssClass="label1">Select the Exit Process</asp:label></TD>
<TD><asp:dropdownlist id="ddlExit" runat="server" CssClass="datacombo">
<asp:ListItem Value="0">select</asp:ListItem>
<asp:ListItem Value="1">NCNS</asp:ListItem>
<asp:ListItem Value="2">Resignation</asp:ListItem>
<asp:ListItem Value="3">Onsite Transfer</asp:ListItem>
</asp:dropdownlist></TD>
</TR>
<TR>
<TD><asp:label id="Label4" runat="server" CssClass="label1">Comments</asp:label></TD>
<TD>
<P><asp:textbox id="txtRMcmts" runat="server" CssClass="mltextbox" TextMode="MultiLine"></asp:textbox>&nbsp;</P>
<P><asp:regularexpressionvalidator id="RegularExpressionValidator1" runat="server" CssClass="textbox1" Width="200px"
ErrorMessage="Minimum 15 characters,Maximum 100 characters Required" controlToValidate="txtRMcmts" ValidationExpression="[,;.&amp;$*()?@+= 0-9a-zA-Z]{15,100}"
ForeColor="red" Font-Size="10"></asp:regularexpressionvalidator></P>
</TD>
</TR>
<TR>
<TD><asp:linkbutton id="LinkButton1" runat="server" CssClass="hLink">View Associate details </asp:linkbutton></TD>
<TD></TD>
</TR>
</TABLE>
<tr>
</tr>
<tr>
<td>
<table width="100%">
<tr>
<td><asp:datagrid id="dgAssociate" runat="server" CssClass="Datagrid" width="100%">
<HeaderStyle CssClass="gridheader"></HeaderStyle>
</asp:datagrid></td>
</tr>
</table>
</td>
</tr>
<tr>
</tr>
</TD></TR>
<tr>
<td>
<table>
<tr>
<td><asp:button id="btnSave" runat="server" CssClass="button" Text="Save"></asp:button>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb sp;&nbsp;
<asp:button id="btnSubmit" runat="server" CssClass="button" Font-Size="Larger" Text="Submit"></asp:button></td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<table width="100%">
<TBODY>
<tr>
<td>
<table width="100%">
<tr>
<td class="label1">FROM DATE&nbsp;&nbsp;&nbsp;&nbsp;
<asp:textbox id="txtfromdate" Runat="server" ReadOnly="True"></asp:textbox>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<asp:hyperlink id="HyperLink1" runat="server" NavigateUrl="javascript: show_calendar('Form1.txtfromdate');"
ImageUrl="Images/cal.gif">HyperLink</asp:hyperlink></td>
<td class="label1">TO DATE&nbsp;&nbsp;&nbsp;&nbsp;
<asp:textbox id="txttodate" Runat="server" ReadOnly="True"></asp:textbox>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<asp:hyperlink id="Hyperlink3" runat="server" NavigateUrl="javascript: show_calendar('Form1.txttodate');"
ImageUrl="Images/cal.gif">HyperLink</asp:hyperlink></td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<table width="100%">
<tr>
<td><asp:datagrid id="dgHistory" runat="server" CssClass="datagrid" Width="100%" Height="154px" PageSize="3"
AllowPaging="True" AutoGenerateColumns="False">
<HeaderStyle CssClass="gridheader"></HeaderStyle>
<Columns>
<asp:BoundColumn DataField="Initiated_by" HeaderText="Initiated_by"></asp:BoundColumn>
<asp:BoundColumn DataField="TransferedAssociate" HeaderText="Transfered_Associate"></asp:BoundColumn>
<asp:BoundColumn DataField="VClient" HeaderText="Client"></asp:BoundColumn>
<asp:BoundColumn DataField="VProcess" HeaderText="Process"></asp:BoundColumn>
<asp:BoundColumn DataField="VSubprocess" HeaderText="Subprocess"></asp:BoundColumn>
<asp:BoundColumn DataField="VLocation" HeaderText="Location"></asp:BoundColumn>
<asp:BoundColumn DataField="VExit_Type" HeaderText="Exit_Type"></asp:BoundColumn>
<asp:BoundColumn DataField="VDate_of_Submit" HeaderText="Date_of_Submit"></asp:BoundColumn>
<asp:BoundColumn DataField="VRM_Comments" HeaderText="RM_Comments"></asp:BoundColumn>
</Columns>
</asp:datagrid></td>
</tr>
<tr>
<td><asp:label id="lblNrf" CssClass="nrf" Font-Size="Larger" Runat="server">No Records Found</asp:label></td>
</tr>
</table>
</td>
</tr>
</TBODY>
</table>
</form>
</TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></FORM>
</body>
</HTML>[/HTML]



.................................................. .................................................. ........

javascript file is calender.js.the code in calender.js is as follows


Expand|Select|Wrap|Line Numbers
  1. var weekend = [0,6];
  2. var weekendColor = "#e0e0e0";
  3. var fontface = "Verdana";
  4. var fontsize = 2;
  5.  
  6. var gNow = new Date();
  7. var ggWinCal;
  8. isNav = (navigator.appName.indexOf("Netscape") != -1) ? true : false;
  9. isIE = (navigator.appName.indexOf("Microsoft") != -1) ? true : false;
  10.  
  11. Calendar.Months = ["January", "February", "March", "April", "May", "June",
  12. "July", "August", "September", "October", "November", "December"];
  13.  
  14. // Non-Leap year Month days..
  15. Calendar.DOMonth = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
  16. // Leap year Month days..
  17. Calendar.lDOMonth = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
  18.  
  19. function Calendar(p_item, p_WinCal, p_month, p_year, p_format) {
  20.     if ((p_month == null) && (p_year == null))    return;
  21.  
  22.     if (p_WinCal == null)
  23.         this.gWinCal = ggWinCal;
  24.     else
  25.         this.gWinCal = p_WinCal;
  26.  
  27.     if (p_month == null) {
  28.         this.gMonthName = null;
  29.         this.gMonth = null;
  30.         this.gYearly = true;
  31.     } else {
  32.         this.gMonthName = Calendar.get_month(p_month);
  33.         this.gMonth = new Number(p_month);
  34.         this.gYearly = false;
  35.     }
  36.  
  37.     this.gYear = p_year;
  38.     this.gFormat = p_format;
  39.     this.gBGColor = "white";
  40.     this.gFGColor = "black";
  41.     this.gTextColor = "black";
  42.     this.gHeaderColor = "black";
  43.     this.gReturnItem = p_item;
  44. }
  45.  
  46. Calendar.get_month = Calendar_get_month;
  47. Calendar.get_daysofmonth = Calendar_get_daysofmonth;
  48. Calendar.calc_month_year = Calendar_calc_month_year;
  49. //Calendar.print = Calendar_print;
  50.  
  51. function Calendar_get_month(monthNo) {
  52.     return Calendar.Months[monthNo];
  53. }
  54.  
  55. function Calendar_get_daysofmonth(monthNo, p_year) {
  56.     /* 
  57.     Check for leap year ..
  58.     1.Years evenly divisible by four are normally leap years, except for... 
  59.     2.Years also evenly divisible by 100 are not leap years, except for... 
  60.     3.Years also evenly divisible by 400 are leap years. 
  61.     */
  62.     if ((p_year % 4) == 0) {
  63.         if ((p_year % 100) == 0 && (p_year % 400) != 0)
  64.             return Calendar.DOMonth[monthNo];
  65.  
  66.         return Calendar.lDOMonth[monthNo];
  67.     } else
  68.         return Calendar.DOMonth[monthNo];
  69. }
  70.  
  71. function Calendar_calc_month_year(p_Month, p_Year, incr) {
  72.     /* 
  73.     Will return an 1-D array with 1st element being the calculated month 
  74.     and second being the calculated year 
  75.     after applying the month increment/decrement as specified by 'incr' parameter.
  76.     'incr' will normally have 1/-1 to navigate thru the months.
  77.     */
  78.     var ret_arr = new Array();
  79.  
  80.     if (incr == -1) {
  81.         // B A C K W A R D
  82.         if (p_Month == 0) {
  83.             ret_arr[0] = 11;
  84.             ret_arr[1] = parseInt(p_Year) - 1;
  85.         }
  86.         else {
  87.             ret_arr[0] = parseInt(p_Month) - 1;
  88.             ret_arr[1] = parseInt(p_Year);
  89.         }
  90.     } else if (incr == 1) {
  91.         // F O R W A R D
  92.         if (p_Month == 11) {
  93.             ret_arr[0] = 0;
  94.             ret_arr[1] = parseInt(p_Year) + 1;
  95.         }
  96.         else {
  97.             ret_arr[0] = parseInt(p_Month) + 1;
  98.             ret_arr[1] = parseInt(p_Year);
  99.         }
  100.     }
  101.  
  102.     return ret_arr;
  103. }
  104.  
  105. //function Calendar_print() {
  106. //    ggWinCal.print();
  107. //}
Expand|Select|Wrap|Line Numbers
  1. function Calendar_calc_month_year(p_Month, p_Year, incr) {
  2.     /* 
  3.     Will return an 1-D array with 1st element being the calculated month 
  4.     and second being the calculated year 
  5.     after applying the month increment/decrement as specified by 'incr' parameter.
  6.     'incr' will normally have 1/-1 to navigate thru the months.
  7.     */
  8.     var ret_arr = new Array();
  9.  
  10.     if (incr == -1) {
  11.         // B A C K W A R D
  12.         if (p_Month == 0) {
  13.             ret_arr[0] = 11;
  14.             ret_arr[1] = parseInt(p_Year) - 1;
  15.         }
  16.         else {
  17.             ret_arr[0] = parseInt(p_Month) - 1;
  18.             ret_arr[1] = parseInt(p_Year);
  19.         }
  20.     } else if (incr == 1) {
  21.         // F O R W A R D
  22.         if (p_Month == 11) {
  23.             ret_arr[0] = 0;
  24.             ret_arr[1] = parseInt(p_Year) + 1;
  25.         }
  26.         else {
  27.             ret_arr[0] = parseInt(p_Month) + 1;
  28.             ret_arr[1] = parseInt(p_Year);
  29.         }
  30.     }
  31.  
  32.     return ret_arr;
  33. }
  34.  
  35. // This is for compatibility with Navigator 3, we have to create and discard one object before the prototype object exists.
  36. new Calendar();
  37.  
  38. Calendar.prototype.getMonthlyCalendarCode = function() {
  39.     var vCode = "";
  40.     var vHeader_Code = "";
  41.     var vData_Code = "";
  42.  
  43.     // Begin Table Drawing code here..
  44.     vCode = vCode + "<TABLE BORDER=1 BGCOLOR=\"" + this.gBGColor + "\">";
  45.  
  46.     vHeader_Code = this.cal_header();
  47.     vData_Code = this.cal_data();
  48.     vCode = vCode + vHeader_Code + vData_Code;
  49.  
  50.     vCode = vCode + "</TABLE>";
  51.  
  52.     return vCode;
  53. }
  54.  
  55. Calendar.prototype.show = function() {
  56.     var vCode = "";
  57.  
  58.     this.gWinCal.document.open();
  59.  
  60.     // Setup the page...
  61.     this.wwrite("<html>");
  62.     this.wwrite("<head><title>Calendar</title>");
  63.     this.wwrite("</head>");
  64.  
  65.     this.wwrite("<body " + 
  66.         "link=\"" + this.gLinkColor + "\" " + 
  67.         "vlink=\"" + this.gLinkColor + "\" " +
  68.         "alink=\"" + this.gLinkColor + "\" " +
  69.         "text=\"" + this.gTextColor + "\">");
  70.     this.wwriteA("<FONT FACE='" + fontface + "' SIZE=2><B>");
  71.     this.wwriteA(this.gMonthName + " " + this.gYear);
  72.     this.wwriteA("</B><BR>");
  73.  
  74.     // Show navigation buttons
  75.     var prevMMYYYY = Calendar.calc_month_year(this.gMonth, this.gYear, -1);
  76.     var prevMM = prevMMYYYY[0];
  77.     var prevYYYY = prevMMYYYY[1];
  78.  
  79.     var nextMMYYYY = Calendar.calc_month_year(this.gMonth, this.gYear, 1);
  80.     var nextMM = nextMMYYYY[0];
  81.     var nextYYYY = nextMMYYYY[1];
  82.  
  83.     this.wwrite("<TABLE WIDTH='100%' BORDER=1 CELLSPACING=0 CELLPADDING=0 BGCOLOR='#e0e0e0'><TR><TD ALIGN=center>");
  84.     this.wwrite("[<A HREF=\"" +
  85.         "javascript:window.opener.Build(" + 
  86.         "'" + this.gReturnItem + "', '" + this.gMonth + "', '" + (parseInt(this.gYear)-1) + "', '" + this.gFormat + "'" +
  87.         ");" +
  88.         "\"><<<\/A>]</TD><TD ALIGN=center>");
  89.     this.wwrite("[<A HREF=\"" +
  90.         "javascript:window.opener.Build(" + 
  91.         "'" + this.gReturnItem + "', '" + prevMM + "', '" + prevYYYY + "', '" + this.gFormat + "'" +
  92.         ");" +
  93.         "\"><<\/A>]</TD><TD ALIGN=center>");
  94.     //this.wwrite("[<A HREF=\"javascript:window.print();\">Print</A>]</TD><TD ALIGN=center>");
  95.     this.wwrite("[<A HREF=\"" +
  96.         "javascript:window.opener.Build(" + 
  97.         "'" + this.gReturnItem + "', '" + nextMM + "', '" + nextYYYY + "', '" + this.gFormat + "'" +
  98.         ");" +
  99.         "\">><\/A>]</TD><TD ALIGN=center>");
  100.     this.wwrite("[<A HREF=\"" +
  101.         "javascript:window.opener.Build(" + 
  102.         "'" + this.gReturnItem + "', '" + this.gMonth + "', '" + (parseInt(this.gYear)+1) + "', '" + this.gFormat + "'" +
  103.         ");" +
  104.         "\">>><\/A>]</TD></TR></TABLE><BR>");
  105.  
  106.     // Get the complete calendar code for the month..
  107.     vCode = this.getMonthlyCalendarCode();
  108.     this.wwrite(vCode);
  109.  
  110.     this.wwrite("</font></body></html>");
  111.     this.gWinCal.document.close();
  112. }
Expand|Select|Wrap|Line Numbers
  1. Calendar.prototype.showY = function() {
  2.     var vCode = "";
  3.     var i;
  4.     var vr, vc, vx, vy;        // Row, Column, X-coord, Y-coord
  5.     var vxf = 285;            // X-Factor
  6.     var vyf = 200;            // Y-Factor
  7.     var vxm = 10;            // X-margin
  8.     var vym;                // Y-margin
  9.     if (isIE)    vym = 75;
  10.     else if (isNav)    vym = 25;
  11.  
  12.     this.gWinCal.document.open();
  13.  
  14.     this.wwrite("<html>");
  15.     this.wwrite("<head><title>Calendar</title>");
  16.     this.wwrite("<style type='text/css'>\n<!--");
  17.     for (i=0; i<12; i++) {
  18.         vc = i % 3;
  19.         if (i>=0 && i<= 2)    vr = 0;
  20.         if (i>=3 && i<= 5)    vr = 1;
  21.         if (i>=6 && i<= 8)    vr = 2;
  22.         if (i>=9 && i<= 11)    vr = 3;
  23.  
  24.         vx = parseInt(vxf * vc) + vxm;
  25.         vy = parseInt(vyf * vr) + vym;
  26.  
  27.         this.wwrite(".lclass" + i + " {position:absolute;top:" + vy + ";left:" + vx + ";}");
  28.     }
  29.     this.wwrite("-->\n</style>");
  30.     this.wwrite("</head>");
  31.  
  32.     this.wwrite("<body " + 
  33.         "link=\"" + this.gLinkColor + "\" " + 
  34.         "vlink=\"" + this.gLinkColor + "\" " +
  35.         "alink=\"" + this.gLinkColor + "\" " +
  36.         "text=\"" + this.gTextColor + "\">");
  37.     this.wwrite("<FONT FACE='" + fontface + "' SIZE=2><B>");
  38.     this.wwrite("Year : " + this.gYear);
  39.     this.wwrite("</B><BR>");
  40.  
  41.     // Show navigation buttons
  42.     var prevYYYY = parseInt(this.gYear) - 1;
  43.     var nextYYYY = parseInt(this.gYear) + 1;
  44.  
  45.     this.wwrite("<TABLE WIDTH='100%' BORDER=1 CELLSPACING=0 CELLPADDING=0 BGCOLOR='#e0e0e0'><TR><TD ALIGN=center>");
  46.     this.wwrite("[<A HREF=\"" +
  47.         "javascript:window.opener.Build(" + 
  48.         "'" + this.gReturnItem + "', null, '" + prevYYYY + "', '" + this.gFormat + "'" +
  49.         ");" +
  50.         "\" alt='Prev Year'><<<\/A>]</TD><TD ALIGN=center>");
  51.     //this.wwrite("[<A HREF=\"javascript:window.print();\">Print</A>]</TD><TD ALIGN=center>");
  52.     this.wwrite("[<A HREF=\"" +
  53.         "javascript:window.opener.Build(" + 
  54.         "'" + this.gReturnItem + "', null, '" + nextYYYY + "', '" + this.gFormat + "'" +
  55.         ");" +
  56.         "\">>><\/A>]</TD></TR></TABLE><BR>");
  57.  
  58.     // Get the complete calendar code for each month..
  59.     var j;
  60.     for (i=11; i>=0; i--) {
  61.         if (isIE)
  62.             this.wwrite("<DIV ID=\"layer" + i + "\" CLASS=\"lclass" + i + "\">");
  63.         else if (isNav)
  64.             this.wwrite("<LAYER ID=\"layer" + i + "\" CLASS=\"lclass" + i + "\">");
  65.  
  66.         this.gMonth = i;
  67.         this.gMonthName = Calendar.get_month(this.gMonth);
  68.         vCode = this.getMonthlyCalendarCode();
  69.         this.wwrite(this.gMonthName + "/" + this.gYear + "<BR>");
  70.         this.wwrite(vCode);
  71.  
  72.         if (isIE)
  73.             this.wwrite("</DIV>");
  74.         else if (isNav)
  75.             this.wwrite("</LAYER>");
  76.     }
  77.  
  78.     this.wwrite("</font><BR></body></html>");
  79.     this.gWinCal.document.close();
  80. }
  81.  
  82. Calendar.prototype.wwrite = function(wtext) {
  83.     this.gWinCal.document.writeln(wtext);
  84. }
  85.  
  86. Calendar.prototype.wwriteA = function(wtext) {
  87.     this.gWinCal.document.write(wtext);
  88. }
  89.  
  90. Calendar.prototype.cal_header = function() {
  91.     var vCode = "";
  92.  
  93.     vCode = vCode + "<TR>";
  94.     vCode = vCode + "<TD WIDTH='14%'><FONT SIZE='2' FACE='" + fontface + "' COLOR='" + this.gHeaderColor + "'><B>Sun</B></FONT></TD>";
  95.     vCode = vCode + "<TD WIDTH='14%'><FONT SIZE='2' FACE='" + fontface + "' COLOR='" + this.gHeaderColor + "'><B>Mon</B></FONT></TD>";
  96.     vCode = vCode + "<TD WIDTH='14%'><FONT SIZE='2' FACE='" + fontface + "' COLOR='" + this.gHeaderColor + "'><B>Tue</B></FONT></TD>";
  97.     vCode = vCode + "<TD WIDTH='14%'><FONT SIZE='2' FACE='" + fontface + "' COLOR='" + this.gHeaderColor + "'><B>Wed</B></FONT></TD>";
  98.     vCode = vCode + "<TD WIDTH='14%'><FONT SIZE='2' FACE='" + fontface + "' COLOR='" + this.gHeaderColor + "'><B>Thu</B></FONT></TD>";
  99.     vCode = vCode + "<TD WIDTH='14%'><FONT SIZE='2' FACE='" + fontface + "' COLOR='" + this.gHeaderColor + "'><B>Fri</B></FONT></TD>";
  100.     vCode = vCode + "<TD WIDTH='16%'><FONT SIZE='2' FACE='" + fontface + "' COLOR='" + this.gHeaderColor + "'><B>Sat</B></FONT></TD>";
  101.     vCode = vCode + "</TR>";
  102.  
  103.     return vCode;
  104. }
  105.  
  106. Calendar.prototype.cal_data = function() {
  107.     var vDate = new Date();
  108.     vDate.setDate(1);
  109.     vDate.setMonth(this.gMonth);
  110.     vDate.setFullYear(this.gYear);
  111.  
  112.     var vFirstDay=vDate.getDay();
  113.     var vDay=1;
  114.     var vLastDay=Calendar.get_daysofmonth(this.gMonth, this.gYear);
  115.     var vOnLastDay=0;
  116.     var vCode = "";
  117.  
  118.     /*
  119.     Get day for the 1st of the requested month/year..
  120.     Place as many blank cells before the 1st day of the month as necessary. 
  121.     */
  122.  
  123.     vCode = vCode + "<TR>";
  124.     for (i=0; i<vFirstDay; i++) {
  125.         vCode = vCode + "<TD WIDTH='14%'" + this.write_weekend_string(i) + "><FONT SIZE='2' FACE='" + fontface + "'> </FONT></TD>";
  126.     }
  127.  
  128.     // Write rest of the 1st week
  129.     for (j=vFirstDay; j<7; j++) {
  130.         vCode = vCode + "<TD WIDTH='14%'" + this.write_weekend_string(j) + "><FONT SIZE='2' FACE='" + fontface + "'>" + 
  131.             "<A HREF='#' " + 
  132.                 "onClick=\"self.opener.document." + this.gReturnItem + ".value='" + 
  133.                 this.format_data(vDay) + 
  134.                 "';window.close();\">" + 
  135.                 this.format_day(vDay) + 
  136.             "</A>" + 
  137.             "</FONT></TD>";
  138.         vDay=vDay + 1;
  139.     }
  140.     vCode = vCode + "</TR>";
  141.  
  142.     // Write the rest of the weeks
  143.     for (k=2; k<7; k++) {
  144.         vCode = vCode + "<TR>";
  145.  
  146.         for (j=0; j<7; j++) {
  147.             vCode = vCode + "<TD WIDTH='14%'" + this.write_weekend_string(j) + "><FONT SIZE='2' FACE='" + fontface + "'>" + 
  148.                 "<A HREF='#' " + 
  149.                     "onClick=\"self.opener.document." + this.gReturnItem + ".value='" + 
  150.                     this.format_data(vDay) + 
  151.                     "';window.close();\">" + 
  152.                 this.format_day(vDay) + 
  153.                 "</A>" + 
  154.                 "</FONT></TD>";
  155.             vDay=vDay + 1;
  156.  
  157.             if (vDay > vLastDay) {
  158.                 vOnLastDay = 1;
  159.                 break;
  160.             }
  161.         }
  162.  
  163.         if (j == 6)
  164.             vCode = vCode + "</TR>";
  165.         if (vOnLastDay == 1)
  166.             break;
  167.     }
  168.  
  169.     // Fill up the rest of last week with proper blanks, so that we get proper square blocks
  170.     for (m=1; m<(7-j); m++) {
  171.         if (this.gYearly)
  172.             vCode = vCode + "<TD WIDTH='14%'" + this.write_weekend_string(j+m) + 
  173.             "><FONT SIZE='2' FACE='" + fontface + "' COLOR='gray'> </FONT></TD>";
  174.         else
  175.             vCode = vCode + "<TD WIDTH='14%'" + this.write_weekend_string(j+m) + 
  176.             "><FONT SIZE='2' FACE='" + fontface + "' COLOR='gray'>" + m + "</FONT></TD>";
  177.     }
  178.  
  179.     return vCode;
  180. }
Expand|Select|Wrap|Line Numbers
  1. Calendar.prototype.format_day = function(vday) {
  2.     var vNowDay = gNow.getDate();
  3.     var vNowMonth = gNow.getMonth();
  4.     var vNowYear = gNow.getFullYear();
  5.  
  6.     if (vday == vNowDay && this.gMonth == vNowMonth && this.gYear == vNowYear)
  7.         return ("<FONT COLOR=\"RED\"><B>" + vday + "</B></FONT>");
  8.     else
  9.         return (vday);
  10. }
  11.  
  12. Calendar.prototype.write_weekend_string = function(vday) {
  13.     var i;
  14.  
  15.     // Return special formatting for the weekend day.
  16.     for (i=0; i<weekend.length; i++) {
  17.         if (vday == weekend[i])
  18.             return (" BGCOLOR=\"" + weekendColor + "\"");
  19.     }
  20.  
  21.     return "";
  22. }
  23.  
  24. Calendar.prototype.format_data = function(p_day) {
  25.     var vData;
  26.     var vMonth = 1 + this.gMonth;
  27.     vMonth = (vMonth.toString().length < 2) ? "0" + vMonth : vMonth;
  28.     var vMon = Calendar.get_month(this.gMonth).substr(0,3).toUpperCase();
  29.     var vFMon = Calendar.get_month(this.gMonth).toUpperCase();
  30.     var vY4 = new String(this.gYear);
  31.     var vY2 = new String(this.gYear.substr(2,2));
  32.     var vDD = (p_day.toString().length < 2) ? "0" + p_day : p_day;
  33.  
  34.     switch (this.gFormat) {
  35.         case "MM\/DD\/YYYY" :
  36.             vData = vMonth + "\/" + vDD + "\/" + vY4;
  37.             break;
  38.         case "MM\/DD\/YY" :
  39.             vData = vMonth + "\/" + vDD + "\/" + vY2;
  40.             break;
  41.         case "MM-DD-YYYY" :
  42.             vData = vMonth + "-" + vDD + "-" + vY4;
  43.             break;
  44.         case "MM-DD-YY" :
  45.             vData = vMonth + "-" + vDD + "-" + vY2;
  46.             break;
  47.  
  48.         case "DD\/MON\/YYYY" :
  49.             vData = vDD + "\/" + vMon + "\/" + vY4;
  50.             break;
  51.         case "DD\/MON\/YY" :
  52.             vData = vDD + "\/" + vMon + "\/" + vY2;
  53.             break;
  54.         case "DD-MON-YYYY" :
  55.             vData = vDD + "-" + vMon + "-" + vY4;
  56.             break;
  57.         case "DD-MON-YY" :
  58.             vData = vDD + "-" + vMon + "-" + vY2;
  59.             break;
  60.  
  61.         case "DD\/MONTH\/YYYY" :
  62.             vData = vDD + "\/" + vFMon + "\/" + vY4;
  63.             break;
  64.         case "DD\/MONTH\/YY" :
  65.             vData = vDD + "\/" + vFMon + "\/" + vY2;
  66.             break;
  67.         case "DD-MONTH-YYYY" :
  68.             vData = vDD + "-" + vFMon + "-" + vY4;
  69.             break;
  70.         case "DD-MONTH-YY" :
  71.             vData = vDD + "-" + vFMon + "-" + vY2;
  72.             break;
  73.  
  74.         case "DD\/MM\/YYYY" :
  75.             vData = vDD + "\/" + vMonth + "\/" + vY4;
  76.             break;
  77.         case "DD\/MM\/YY" :
  78.             vData = vDD + "\/" + vMonth + "\/" + vY2;
  79.             break;
  80.         case "DD-MM-YYYY" :
  81.             vData = vDD + "-" + vMonth + "-" + vY4;
  82.             break;
  83.         case "DD-MM-YY" :
  84.             vData = vDD + "-" + vMonth + "-" + vY2;
  85.             break;
  86.  
  87.         default :
  88.             vData = vMonth + "\/" + vDD + "\/" + vY4;
  89.     }
  90.  
  91.     return vData;
  92. }
  93.  
  94. function Build(p_item, p_month, p_year, p_format) {
  95.     var p_WinCal = ggWinCal;
  96.     gCal = new Calendar(p_item, p_WinCal, p_month, p_year, p_format);
  97.  
  98.     // Customize your Calendar here..
  99.     gCal.gBGColor="white";
  100.     gCal.gLinkColor="black";
  101.     gCal.gTextColor="black";
  102.     gCal.gHeaderColor="darkgreen";
  103.  
  104.     // Choose appropriate show function
  105.     if (gCal.gYearly)    gCal.showY();
  106.     else    gCal.show();
  107. }
  108.  
  109. function show_calendar() {
  110.     /* 
  111.         p_month : 0-11 for Jan-Dec; 12 for All Months.
  112.         p_year    : 4-digit year
  113.         p_format: Date format (mm/dd/yyyy, dd/mm/yy, ...)
  114.         p_item    : Return Item.
  115.     */
  116.  
  117.     p_item = arguments[0];
  118.     if (arguments[1] == null)
  119.         p_month = new String(gNow.getMonth());
  120.     else
  121.         p_month = arguments[1];
  122.     if (arguments[2] == "" || arguments[2] == null)
  123.         p_year = new String(gNow.getFullYear().toString());
  124.     else
  125.         p_year = arguments[2];
  126.     if (arguments[3] == null)
  127.         p_format = "MM/DD/YYYY";
  128.         //p_format = "DD/MM/YYYY";
  129.     else
  130.         p_format = arguments[3];
  131.  
  132.     vWinCal = window.open("", "Calendar", 
  133.         "width=250,height=250,status=no,resizable=no,top=200,left=200");
  134.     vWinCal.opener = self;
  135.     ggWinCal = vWinCal;
  136.  
  137.     Build(p_item, p_month, p_year, p_format);
  138. }
  139. /*
  140. Yearly Calendar Code Starts here
  141. */
  142. function show_yearly_calendar(p_item, p_year, p_format) {
  143.     // Load the defaults..
  144.     if (p_year == null || p_year == "")
  145.         p_year = new String(gNow.getFullYear().toString());
  146.     if (p_format == null || p_format == "")
  147.         p_format = "MM/DD/YYYY";
  148.  
  149.     var vWinCal = window.open("", "Calendar", "scrollbars=yes");
  150.     vWinCal.opener = self;
  151.     ggWinCal = vWinCal;
  152.  
  153.     Build(p_item, null, p_year, p_format);
  154. }
Jan 29 '08 #1
Share this Question
Share on Google+
1 Reply


acoder
Expert Mod 15k+
P: 16,027
Welcome to TSDN!

What line does the error occur on?
Jan 29 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.