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

Microsoft JScript runtime error: is null or not an object

P: 2
Hello

I'm having the following problem:

My main webpage calls a function stored in a .js file that creates an HTML window to display a calendar. Whenever I click on a date in that calendar,
the calendar should return to the main webpage, but it cannot find the home window again. I'm getting this error:

Microsoft JScript runtime error: 'self.opener.document.idFormMain.txtPeriodOfOperat ionEff' is null or not an object

I've successfully used this before, but I'm at a loss why it's not working here.

I've included relevant parts the source code that I'm using as follows:

Part <A> is a section of the HTML in my main webpage that creates the Calendar Window.
Part <B> is a javascript function at the bottom of the main HTML page that's called from the highlighted line in <A>
Part <C> is the HTML of the Calendar Window that is created by calendar.js

For copyright reasons (i.e. I don't own it), I'm afraid I can't include the source for calendar.js.

Can anyone help me?

Thanks much in advance.
Expand|Select|Wrap|Line Numbers
  1. =================================BEGIN Part A=================================
  2. <script src='calender.js' type='text/javascript'></script>
  3.  
  4. <!-- Begin Main (Right-Side, Bottom) -->
  5. <tr valign='top' style='height: 184px'>
  6. <td align='center' valign='top' style='font-family: tahoma,verdana,arial,sans-serif; font-size: 11px; font-weight: bold; color: #000000; padding: 0px;'>
  7. <span id="spnForm" runat="server" /> 
  8. <form id='idFormMain' method='post'>
  9. <hr size='1' style='color: #808000; border-top-style: solid; border-right-style: solid; border-left-style: solid; border-bottom-style: solid;' noshade/>
  10. <!-- Master Data Input Table -->
  11. <table id='idtblMasterDataInput' style='width: 720px;' border='0' cellpadding='0' cellspacing='0'>
  12. <!-- Row 3 of Master Data Input Table -->
  13. <tr>
  14. <td align='left' valign='middle' style='width: 100%; padding-right: 0px; padding-left: 0px; font-size: 11px; padding-bottom: 0px; color: #000000; padding-top: 0px; font-family: tahoma,verdana,arial,sans-serif; background-color: #ffffff; border-bottom-width: 1px; border-bottom-color: #d1b172;'>
  15. <!-- Container Table for Row 3 of Master Data Input Table -->
  16. <table id='idtblMasterDataInputRow3' style='width: 100%;' border='0' cellpadding='0' cellspacing='0'>
  17. <tr>
  18. <td align='left' valign='middle' style='width: 30%'>
  19. <!-- Effective Date Input Subtable -->
  20. <table id='idtblPeriodOfOperationEff' style='width: 100%;' border='0' cellpadding='0' cellspacing='0'>
  21. <tr>
  22. <td align='left' valign='middle' style='width: 33%; padding-right: 0px; padding-left: 6px; font-size: 11px; padding-bottom: 0px; color: #000000; padding-top: 1px; font-family: tahoma,verdana,arial,san-serif; background-color: #ffffff;'>
  23. Effective Date:
  24. </td>
  25. <td align='left' valign='middle' style='width: 47%; padding-right: 0px; padding-left: 6px; font-size: 11px; padding-bottom: 0px; color: #000000; padding-top: 1px; font-family: tahoma,verdana,arial,sans-serif; background-color: #ffffff;'>
  26. <input type='text' id='txtPeriodOfOperationEff' name='txtPeriodOfOperationEff' maxlength='10' runat='server' style='padding-right: 0px; padding-left: 6px; font-size: 11px; padding-bottom: 0px; text-transform: uppercase; width: 90%; color: #000000; padding-top: 1px; font-family: tahoma,verdana,arial,sans-serif; background-color: #ffffff;' />
  27. </td>
  28. <td align='left' valign='middle' style='width: 20%; padding-right: 0px; padding-left: 6px; font-size: 11px; padding-bottom: 0px; color: #000000; padding-top: 1px; font-family: tahoma,verdana,arial,sans-serif; background-color: #ffffff;'>
  29. <img border='0' src='/img/calendar1.gif' onclick="javascript:pop_cal('txtPeriodOfOperationEff')" width="16" height="16"/>
  30. </td>
  31. </tr>
  32. </table>
  33. </td>
  34. <td align='left' valign='middle' style='width: 30%'>
  35. <!-- Discontinue Date Input Subtable -->
  36. <table id='idtblPeriodOfOperationDisc' style='width: 100%;' border='0' cellpadding='0' cellspacing='0'>
  37. <tr>
  38. <td align='left' valign='middle' style='width: 36%; padding-right: 0px; padding-left: 6px; font-size: 11px; padding-bottom: 0px; color: #000000; padding-top: 1px; font-family: tahoma,verdana,arial,san-serif; background-color: #ffffff;'>
  39. Discontinue Date:
  40. </td>
  41. <td align='left' valign='middle' style='width: 44%; padding-right: 0px; padding-left: 6px; font-size: 11px; padding-bottom: 0px; color: #000000; padding-top: 1px; font-family: tahoma,verdana,arial,sans-serif; background-color: #ffffff;'>
  42. <input type='text' id='txtPeriodOfOperationDisc' name='txtPeriodOfOperationDisc' maxlength='10' runat='server' style='padding-right: 0px; padding-left: 6px; font-size: 11px; padding-bottom: 0px; text-transform: uppercase; width: 90%; color: #000000; padding-top: 1px; font-family: tahoma,verdana,arial,sans-serif; background-color: #ffffff;' />
  43. </td>
  44. <td align='left' valign='middle' style='width: 20%; padding-right: 0px; padding-left: 6px; font-size: 11px; padding-bottom: 0px; color: #000000; padding-top: 1px; font-family: tahoma,verdana,arial,sans-serif; background-color: #ffffff;'>
  45. <img border='0' src='/img/calendar1.gif' onclick="javascript:pop_cal('txtPeriodOfOperationDisc')" width="16" height="16"/>
  46. </td>
  47. </tr>
  48. </table>
  49. </td>
  50. </tr>
  51. </table>
  52. </td>
  53. </tr>
  54. </table>
  55. </form>
  56. </td>
  57. </tr>
  58. ==================================END Part A==================================
  59.  
Expand|Select|Wrap|Line Numbers
  1. =================================BEGIN Part B=================================
  2. <script type="text/javascript">
  3. function pop_cal(ival)
  4. {
  5. show_calendar('idFormMain.' + ival); // show_calendar() is a function within calendar.js
  6. }
  7. </script>
  8. ==================================END Part B==================================
  9.  
  10. =================================BEGIN Part C=================================
  11. <html>
  12. <head><title>Calendar</title>
  13. </head>
  14. <body BGCOLOR='#FFFFFF' link="black" vlink="black" alink="black" text="black" STYLE="font-family: tahoma,verdana,arial,sans-serif; font-size: 1px; font-weight: normal; color: #000000;">
  15. <CENTER><FONT STYLE="font-family: tahoma,verdana,arial,sans-serif; font-size: 13px; font-weight: bold; color: #000000;">May 2007</FONT></CENTER><TABLE WIDTH='100%' BORDER=1 CELLSPACING=0 CELLPADDING=0 BGCOLOR='#F0F0F0' BORDERCOLOR='#000000' STYLE='width: 230px; font-family: tahoma,verdana,arial,sans-serif; font-size: 11px; font-weight: normal; color: #000000; border-collapse: collapse;'><TR><TD ALIGN=center valign=bottom style='height:20px;'>
  16. <A HREF="javascript:window.opener.Build('idFormMain.txtPeriodOfOperationEff', '4', '2006', 'MM/DD/YYYY');"> <img src='/img/nav_begin.gif' border=0> </A></TD><TD ALIGN=center VALIGN=bottom>
  17. <A HREF="javascript:window.opener.Build('idFormMain.txtPeriodOfOperationEff', '3', '2007', 'MM/DD/YYYY');"> <img src='/img/nav_prev.gif' border=0> </A></TD><TD ALIGN=center VALIGN=bottom>
  18. <A HREF="javascript:window.opener.Build('idFormMain.txtPeriodOfOperationEff', '5', '2007', 'MM/DD/YYYY');"> <img src='/img/nav_next.gif' border=0> </A></TD><TD ALIGN=center VALIGN=bottom>
  19. <A HREF="javascript:window.opener.Build('idFormMain.txtPeriodOfOperationEff', '4', '2008', 'MM/DD/YYYY');"> <img src='/img/nav_end.gif' border=0> </A></TD></TR></TABLE><BR>
  20. <TABLE BORDER=1 CELLSPACING=0 CELLPADDING=0' BORDERCOLOR='#000099' STYLE='width: 230px; font-family: tahoma,verdana,arial,sans-serif; font-size: 11px; font-weight: normal; color: #000000; border-collapse: collapse;'><TR><TD ALIGN='CENTER' VALIGN='MIDDLE' WIDTH='14%' STYLE='height: 20px; font-family: tahoma,verdana,arial,sans-serif; font-size: 11px; font-weight: bold; color: #FFFFFF; background-color: #000099;'>S</TD><TD ALIGN='CENTER' VALIGN='MIDDLE' WIDTH='14%' STYLE='height: 20px; font-family: tahoma,verdana,arial,sans-serif; font-size: 11px; font-weight: bold; color: #FFFFFF; background-color: #000099;'>M</TD><TD ALIGN='CENTER' VALIGN='MIDDLE' WIDTH='14%' STYLE='height: 20px; font-family: tahoma,verdana,arial,sans-serif; font-size: 11px; font-weight: bold; color: #FFFFFF; background-color: #000099;'>T</TD><TD ALIGN='CENTER' VALIGN='MIDDLE' WIDTH='14%' STYLE='height: 20px; font-family: tahoma,verdana,arial,sans-serif; font-size: 11px; font-weight: bold; color: #FFFFFF; background-color: #000099;'>W</TD><TD ALIGN='CENTER' VALIGN='MIDDLE' WIDTH='14%' STYLE='height: 20px; font-family: tahoma,verdana,arial,sans-serif; font-size: 11px; font-weight: bold; color: #FFFFFF; background-color: #000099;'>T</TD><TD ALIGN='CENTER' VALIGN='MIDDLE' WIDTH='14%' STYLE='height: 20px; font-family: tahoma,verdana,arial,sans-serif; font-size: 11px; font-weight: bold; color: #FFFFFF; background-color: #000099;'>F</TD><TD ALIGN='CENTER' VALIGN='MIDDLE' WIDTH='16%' STYLE='height: 20px; font-family: tahoma,verdana,arial,sans-serif; font-size: 11px; font-weight: bold; color: #FFFFFF; background-color: #000099;'>S</TD></TR><TR><TD WIDTH='14%' BGCOLOR="#E0E0C0"><FONT SIZE='2' FACE='Verdana'>&nbsp;</FONT></TD><TD WIDTH='14%'><FONT SIZE='2' FACE='Verdana'>&nbsp;</FONT></TD><TD WIDTH='14%'><FONT SIZE='2' FACE='Verdana'><A HREF='#' onClick="self.opener.document.idFormMain.txtPeriodOfOperationEff.value='05/01/2007';self.opener.document.idFormMain.txtPeriodOfOperationEff.focus();window.close();">1</A></FONT></TD><TD WIDTH='14%'><FONT SIZE='2' FACE='Verdana'><A HREF='#' onClick="self.opener.document.idFormMain.txtPeriodOfOperationEff.value='05/02/2007';self.opener.document.idFormMain.txtPeriodOfOperationEff.focus();window.close();">2</A></FONT></TD><TD WIDTH='14%'><FONT SIZE='2' FACE='Verdana'><A HREF='#' onClick="self.opener.document.idFormMain.txtPeriodOfOperationEff.value='05/03/2007';self.opener.document.idFormMain.txtPeriodOfOperationEff.focus();window.close();">3</A></FONT></TD><TD WIDTH='14%'><FONT SIZE='2' FACE='Verdana'><A HREF='#' onClick="self.opener.document.idFormMain.txtPeriodOfOperationEff.value='05/04/2007';self.opener.document.idFormMain.txtPeriodOfOperationEff.focus();window.close();">4</A></FONT></TD><TD WIDTH='14%' BGCOLOR="#E0E0C0"><FONT SIZE='2' FACE='Verdana'><A HREF='#' onClick="self.opener.document.idFormMain.txtPeriodOfOperationEff.value='05/05/2007';self.opener.document.idFormMain.txtPeriodOfOperationEff.focus();window.close();">5</A></FONT></TD></TR><TR><TD WIDTH='14%' BGCOLOR="#E0E0C0"><FONT SIZE='2' FACE='Verdana'><A HREF='#' onClick="self.opener.document.idFormMain.txtPeriodOfOperationEff.value='05/06/2007';self.opener.document.idFormMain.txtPeriodOfOperationEff.focus();window.close();">6</A></FONT></TD><TD WIDTH='14%'><FONT SIZE='2' FACE='Verdana'><A HREF='#' onClick="self.opener.document.idFormMain.txtPeriodOfOperationEff.value='05/07/2007';self.opener.document.idFormMain.txtPeriodOfOperationEff.focus();window.close();">7</A></FONT></TD><TD WIDTH='14%'><FONT SIZE='2' FACE='Verdana'><A HREF='#' onClick="self.opener.document.idFormMain.txtPeriodOfOperationEff.value='05/08/2007';self.opener.document.idFormMain.txtPeriodOfOperationEff.focus();window.close();">8</A></FONT></TD><TD WIDTH='14%'><FONT SIZE='2' FACE='Verdana'><A HREF='#' onClick="self.opener.document.idFormMain.txtPeriodOfOperationEff.value='05/09/2007';self.opener.document.idFormMain.txtPeriodOfOperationEff.focus();window.close();">9</A></FONT></TD><TD WIDTH='14%'><FONT SIZE='2' FACE='Verdana'><A HREF='#' onClick="self.opener.document.idFormMain.txtPeriodOfOperationEff.value='05/10/2007';self.opener.document.idFormMain.txtPeriodOfOperationEff.focus();window.close();">10</A></FONT></TD><TD WIDTH='14%'><FONT SIZE='2' FACE='Verdana'><A HREF='#' onClick="self.opener.document.idFormMain.txtPeriodOfOperationEff.value='05/11/2007';self.opener.document.idFormMain.txtPeriodOfOperationEff.focus();window.close();">11</A></FONT></TD><TD WIDTH='14%' BGCOLOR="#E0E0C0"><FONT SIZE='2' FACE='Verdana'><A HREF='#' onClick="self.opener.document.idFormMain.txtPeriodOfOperationEff.value='05/12/2007';self.opener.document.idFormMain.txtPeriodOfOperationEff.focus();window.close();">12</A></FONT></TD><TR><TD WIDTH='14%' BGCOLOR="#E0E0C0"><FONT SIZE='2' FACE='Verdana'><A HREF='#' onClick="self.opener.document.idFormMain.txtPeriodOfOperationEff.value='05/13/2007';self.opener.document.idFormMain.txtPeriodOfOperationEff.focus();window.close();">13</A></FONT></TD><TD WIDTH='14%'><FONT SIZE='2' FACE='Verdana'><A HREF='#' onClick="self.opener.document.idFormMain.txtPeriodOfOperationEff.value='05/14/2007';self.opener.document.idFormMain.txtPeriodOfOperationEff.focus();window.close();">14</A></FONT></TD><TD WIDTH='14%'><FONT SIZE='2' FACE='Verdana'><A HREF='#' onClick="self.opener.document.idFormMain.txtPeriodOfOperationEff.value='05/15/2007';self.opener.document.idFormMain.txtPeriodOfOperationEff.focus();window.close();">15</A></FONT></TD><TD WIDTH='14%'><FONT SIZE='2' FACE='Verdana'><A HREF='#' onClick="self.opener.document.idFormMain.txtPeriodOfOperationEff.value='05/16/2007';self.opener.document.idFormMain.txtPeriodOfOperationEff.focus();window.close();">16</A></FONT></TD><TD WIDTH='14%'><FONT SIZE='2' FACE='Verdana'><A HREF='#' onClick="self.opener.document.idFormMain.txtPeriodOfOperationEff.value='05/17/2007';self.opener.document.idFormMain.txtPeriodOfOperationEff.focus();window.close();">17</A></FONT></TD><TD WIDTH='14%'><FONT SIZE='2' FACE='Verdana'><A HREF='#' onClick="self.opener.document.idFormMain.txtPeriodOfOperationEff.value='05/18/2007';self.opener.document.idFormMain.txtPeriodOfOperationEff.focus();window.close();"><FONT COLOR="RED"><B>18</B></FONT></A></FONT></TD><TD WIDTH='14%' BGCOLOR="#E0E0C0"><FONT SIZE='2' FACE='Verdana'><A HREF='#' onClick="self.opener.document.idFormMain.txtPeriodOfOperationEff.value='05/19/2007';self.opener.document.idFormMain.txtPeriodOfOperationEff.focus();window.close();">19</A></FONT></TD><TR><TD WIDTH='14%' BGCOLOR="#E0E0C0"><FONT SIZE='2' FACE='Verdana'><A HREF='#' onClick="self.opener.document.idFormMain.txtPeriodOfOperationEff.value='05/20/2007';self.opener.document.idFormMain.txtPeriodOfOperationEff.focus();window.close();">20</A></FONT></TD><TD WIDTH='14%'><FONT SIZE='2' FACE='Verdana'><A HREF='#' onClick="self.opener.document.idFormMain.txtPeriodOfOperationEff.value='05/21/2007';self.opener.document.idFormMain.txtPeriodOfOperationEff.focus();window.close();">21</A></FONT></TD><TD WIDTH='14%'><FONT SIZE='2' FACE='Verdana'><A HREF='#' onClick="self.opener.document.idFormMain.txtPeriodOfOperationEff.value='05/22/2007';self.opener.document.idFormMain.txtPeriodOfOperationEff.focus();window.close();">22</A></FONT></TD><TD WIDTH='14%'><FONT SIZE='2' FACE='Verdana'><A HREF='#' onClick="self.opener.document.idFormMain.txtPeriodOfOperationEff.value='05/23/2007';self.opener.document.idFormMain.txtPeriodOfOperationEff.focus();window.close();">23</A></FONT></TD><TD WIDTH='14%'><FONT SIZE='2' FACE='Verdana'><A HREF='#' onClick="self.opener.document.idFormMain.txtPeriodOfOperationEff.value='05/24/2007';self.opener.document.idFormMain.txtPeriodOfOperationEff.focus();window.close();">24</A></FONT></TD><TD WIDTH='14%'><FONT SIZE='2' FACE='Verdana'><A HREF='#' onClick="self.opener.document.idFormMain.txtPeriodOfOperationEff.value='05/25/2007';self.opener.document.idFormMain.txtPeriodOfOperationEff.focus();window.close();">25</A></FONT></TD><TD WIDTH='14%' BGCOLOR="#E0E0C0"><FONT SIZE='2' FACE='Verdana'><A HREF='#' onClick="self.opener.document.idFormMain.txtPeriodOfOperationEff.value='05/26/2007';self.opener.document.idFormMain.txtPeriodOfOperationEff.focus();window.close();">26</A></FONT></TD><TR><TD WIDTH='14%' BGCOLOR="#E0E0C0"><FONT SIZE='2' FACE='Verdana'><A HREF='#' onClick="self.opener.document.idFormMain.txtPeriodOfOperationEff.value='05/27/2007';self.opener.document.idFormMain.txtPeriodOfOperationEff.focus();window.close();">27</A></FONT></TD><TD WIDTH='14%'><FONT SIZE='2' FACE='Verdana'><A HREF='#' onClick="self.opener.document.idFormMain.txtPeriodOfOperationEff.value='05/28/2007';self.opener.document.idFormMain.txtPeriodOfOperationEff.focus();window.close();">28</A></FONT></TD><TD WIDTH='14%'><FONT SIZE='2' FACE='Verdana'><A HREF='#' onClick="self.opener.document.idFormMain.txtPeriodOfOperationEff.value='05/29/2007';self.opener.document.idFormMain.txtPeriodOfOperationEff.focus();window.close();">29</A></FONT></TD><TD WIDTH='14%'><FONT SIZE='2' FACE='Verdana'><A HREF='#' onClick="self.opener.document.idFormMain.txtPeriodOfOperationEff.value='05/30/2007';self.opener.document.idFormMain.txtPeriodOfOperationEff.focus();window.close();">30</A></FONT></TD><TD WIDTH='14%'><FONT SIZE='2' FACE='Verdana'><A HREF='#' onClick="self.opener.document.idFormMain.txtPeriodOfOperationEff.value='05/31/2007';self.opener.document.idFormMain.txtPeriodOfOperationEff.focus();window.close();">31</A></FONT></TD><TD WIDTH='14%'><FONT SIZE='2' FACE='Verdana' COLOR='gray'>1</FONT></TD><TD WIDTH='14%' BGCOLOR="#E0E0C0"><FONT SIZE='2' FACE='Verdana' COLOR='gray'>2</FONT></TD></TABLE>
  21. <CENTER><FONT STYLE="font-family: tahoma,verdana,arial,sans-serif; font-size: 11px; font-weight: normal; color: #000000;">[ <A HREF="javascript:window.close();">Close Calendar</A> ]</FONT></CENTER>
  22. </font></body></html>
  23. ==================================END Part C==================================
  24.  
May 18 '07 #1
Share this Question
Share on Google+
1 Reply


acoder
Expert Mod 15k+
P: 16,027
This is a typical example of misusing IDs in place of names. That syntax requires the form to have a name "idFormMain". Either add that name to the form or change all references to self.opener.document.idFormMain to self.opener.document.getElementById("idFormMain").
Jun 7 '08 #2

Post your reply

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