Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    New to the CF scene
    Join Date
    Jul 2005
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    "... is null or not an object" error question

    I can't figure out this issue. I'm trying to add a button (Import) to an existing page. Here is the code...

    Code:
    </script>
    
    <body>
    <form>
    <center>
    
    <script>
    
      // Write out button code based on value of argument received. This writes out buttons
      // that are available for a given screen (not all buttons are available for all screens).
      // If the button is not available, write out a blank image as a place holder. Include a
      // blank space between each button.
        
     // IMPORT button
      if(buttons_in.search('IMP')>= 0) {
        parent.bottom.document.imp_button_on = new Image(21, 57);
        parent.bottom.document.imp_button_on.src = "../images/import_on.gif";
        document.write('<a href = "javascript:buttonClicked(\'IMP\');"><img src="../images/import_off.gif" name="button_funct_imp" width="57" height="21" border="0"></a>&nbsp\n')
      }
      else {
        document.write('<img src="../images/blank.gif" name="button_funct_imp" width="1" height="1" border="0">')
      }
      
      // ADD button
      if(buttons_in.search('ADD')>= 0) {
        parent.bottom.document.add_button_on = new Image(21, 57);
        parent.bottom.document.add_button_on.src = "../images/add_on.gif";
        document.write('<a href = "javascript:buttonClicked(\'ADD\');"><img src="../images/add_off.gif" name="button_funct_add" width="57" height="21" border="0"></a>&nbsp\n')
      }
      else {
        document.write('<img src="../images/blank.gif" name="button_funct_add" width="1" height="1" border="0">')
      }
     
      // CHANGE button
      if(buttons_in.search('CHG') >= 0) {
        parent.bottom.document.chg_button_on = new Image(21, 57);
        parent.bottom.document.chg_button_on.src = "../images/change_on.gif";
        document.write('<a href = "javascript:buttonClicked(\'CHANGE\');"><img src="../images/change_off.gif" name="button_funct_chg" width="57" height="21" border="0"></a>&nbsp\n')
      }
      else {
        document.write('<img src="../images/blank.gif" name="button_funct_chg" width="1" height="1" border="0">')
      }
    
      // DELETE button 
      if(buttons_in.search('DEL') >= 0) {
        parent.bottom.document.del_button_on = new Image(21, 57);
        parent.bottom.document.del_button_on.src = "../images/delete_on.gif";
        document.write('<a href = "javascript:buttonClicked(\'DELETE\');"><img src="../images/delete_off.gif" name="button_funct_del" width="57" height="21" border="0"></a>&nbsp\n')
      }   
      else {
        document.write('<img src="../images/blank.gif" name="button_funct_del" width="1" height="1" border="0">')
      }
     
      // DESIGN button
      if(buttons_in.search('DSG') >= 0) {
        parent.bottom.document.dsg_button_on = new Image(21, 57);
        parent.bottom.document.dsg_button_on.src = "../images/design_on.gif";
        document.write('<a href = "javascript:buttonClicked(\'DESIGN\');"><img src="../images/design_off.gif" name="button_funct_dsg" width="57" height="21" border="0"></a>&nbsp\n')
      }   
      else {
        document.write('<img src="../images/blank.gif" name="button_funct_dsg" width="1" height="1" border="0">')
      }
    
      // EXCEL button
      if(buttons_in.search('EXL') >= 0) {
        parent.bottom.document.exl_button_on = new Image(21, 57);
        parent.bottom.document.exl_button_on.src = "../images/excel_on.gif";
        document.write('<a href = "javascript:buttonClicked(\'EXCEL\');"><img src="../images/excel_off.gif" name="button_funct_exl" width="57" height="21" border="0"></a>&nbsp\n')
      }   
      else {
        document.write('<img src="../images/blank.gif" name="button_funct_exl" width="1" height="1" border="0">')
      }
    
      // RESET button
      if(buttons_in.search('RES') >= 0) {
        parent.bottom.document.res_button_on = new Image(21, 57);
        parent.bottom.document.res_button_on.src = "../images/reset_on.gif";
         document.write('<a href = "javascript:buttonClicked(\'RESET\');"><img src="../images/reset_off.gif" name="button_funct_res" width="57" height="21" border="0"></a>&nbsp\n')
       }   
      else {
        document.write('<img src="../images/blank.gif" name="button_funct_res" width="1" height="1" border="0">')
      }
      
       
      // Always print the help button on each screen and put some space before it.
      document.write('&nbsp;&nbsp;&nbsp;&nbsp;');
      document.write('<a href = javascript:showHelp("english");><img src="../images/help_on.gif" name="button_funct_help" width="57" height="21" border="0"></a>&nbsp\n')
      
      // Write message area text box and ake sure that it can't be accessed by the user.
      // When focus is put on it, remove focus (blur).
      document.write('<br>\n')
      document.write('<input type="text" name="message_area" size="65" onFocus=this.blur()>\n')
      
      // Add a standard footer listing Ford copyright, document author/owner, Last Revised date.
      document.write('<table border="0" width="100%"><tr>\n')
      document.write('<td width="38%" align="left" valign="top"><font size="1">©1998, Ford Motor Company</font></td>\n')
      document.write('<td width="24%" align="center" valign="top"><font size="1">Owner: <a href="http://hub.ford.com:8081/ldap.cgi?name=cmms3bar&pType=0&bType=0&qtext=%2b%2b&cdText=%2b%2b&pMode=1" target="workarea">CMMS3BAR</a></font></td>\n')
      document.write('<td width="38%" align="right" valign="top"><font size="1">Last Revised: ' + dateTime(new Date(Date.parse(document.lastModified))) + '</font></td></tr></table>\n')
    
    </script>    
    
    </center>
    </form>
    </body>
    </html>
    All the other buttons other than the Import, which I am trying to add work. The error I get is "parent.bottom.document.imp_button_on.src is null or not an object". The image path is correct, because if I swap it with the code for a working button, I see the image.

  • #2
    Senior Coder nikkiH's Avatar
    Join Date
    Jun 2005
    Location
    Near Chicago, IL, USA
    Posts
    1,973
    Thanks
    1
    Thanked 32 Times in 31 Posts
    Well, what's the code in the bottom frame for
    parent.bottom.document.imp_button_on

    Are you sure you have an element named that (case-sensitive)?
    The error is about the object, not the image. It thinks you don't have an element named imp_button_on in that document.

    That's all I can think of off the top of my head.

    If this post contains any code, I may or may not have tested it. It's probably just example code, so no getting knickers in a bunch over a typo, OK? If it doesn't have basic error checking in it, such as object detection or checking if objects are null before using them, put that in there. I'm giving examples, not typing up your whole app for you. You run code at your own risk.
    Bored? Visit
    http://www.kaelisspace.com/

  • #3
    New to the CF scene
    Join Date
    Jul 2005
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks for the response. I believe the object is present. Here is the code that creates the object...

    Code:
    function updateFooter(buttons, screen_message, error_message) {
     
        // Write out button code based on value of argument received. Include a blank space
        // between each button. Buttons come in as uppercase so btn_array is in uppercase
        // in order for the buttons.search to work. They then need to be changed to lowercase
        // for reference to the actual image and object names.
        
        var btn_array = ['IMP' ,'ADD', 'CHG', 'DEL', 'RES', 'DSG', 'EXL'];
    
        for(var i=0; i < btn_array.length; i++) {
           if(buttons.search(btn_array[i]) >= 0) {
              var lc_btn = btn_array[i].toLowerCase(); 
              image_name = '"button_funct_' + lc_btn + '"';
              image_object = lc_btn + '_button_on.src';
              eval('parent.bottom.document.images[' + image_name + '].src = parent.bottom.document.' + image_object);
           }
        }
    I added IMP to btn_array and still get the error, but all the other buttons function.

  • #4
    Senior Coder nikkiH's Avatar
    Join Date
    Jun 2005
    Location
    Near Chicago, IL, USA
    Posts
    1,973
    Thanks
    1
    Thanked 32 Times in 31 Posts
    I don't suppose you have the full thing online anywhere?

    If this post contains any code, I may or may not have tested it. It's probably just example code, so no getting knickers in a bunch over a typo, OK? If it doesn't have basic error checking in it, such as object detection or checking if objects are null before using them, put that in there. I'm giving examples, not typing up your whole app for you. You run code at your own risk.
    Bored? Visit
    http://www.kaelisspace.com/

  • #5
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Try changing the name...
    import is probably a reserved word but I'm too lazy to check...
    But, if everything else works... Betting on a reserved word would be a safe bet...
    Besides, import sounds as if it should be reserved...

    .....Willy

  • #6
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,919
    Thanks
    203
    Thanked 2,531 Times in 2,509 Posts
    import is indeed a reserved word (and so is export).

  • #7
    Senior Coder nikkiH's Avatar
    Join Date
    Jun 2005
    Location
    Near Chicago, IL, USA
    Posts
    1,973
    Thanks
    1
    Thanked 32 Times in 31 Posts
    It is, but he's abbreviating it to IMP, so I don't think that's the issue...

    If this post contains any code, I may or may not have tested it. It's probably just example code, so no getting knickers in a bunch over a typo, OK? If it doesn't have basic error checking in it, such as object detection or checking if objects are null before using them, put that in there. I'm giving examples, not typing up your whole app for you. You run code at your own risk.
    Bored? Visit
    http://www.kaelisspace.com/

  • #8
    New to the CF scene
    Join Date
    Jul 2005
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Problem solved!!! The variables for the button functions were actually being passed from the menu bar portion of the screen (in which I hadn't added 'IMP'). Thanks you guys for the effort and I appologize for wasting your time.



  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •