is null or not an object error depending on order of code

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rmurgia
    New Member
    • May 2008
    • 63

    is null or not an object error depending on order of code

    I need to determine which key was pressed, then do some error checking and finally determine which screen to load. The following code was used to determine which screen was pressed:

    var strkp = document.presse d;

    The screen was set after doing some error checking and determining which screen to load:
    document.frmMAS Maint_02.action = "frmMASMaint_02 .asp";

    When the above code is placed after document.presse d, it works. When there is other code added, such as some debuging code like:

    document.write( strkp);

    The 2nd line errrors out with:

    Error: document.frmMAS Maint_02 is null or not an object.

    It appears that somehow the frmMASMaint_02 is being removed from memory.

    Does anyone have any idea if the DOM object has some quirks which would make this happen. Any ideas would be greatly apreciated.
  • gits
    Recognized Expert Moderator Expert
    • May 2007
    • 5388

    #2
    you cannot use

    [CODE=javascript]document.write( )[/CODE] with a loaded document ... this will destroy the current dom-tree ... make an alert or use a div and set its innerHTML instead ...

    kind regards

    Comment

    • rmurgia
      New Member
      • May 2008
      • 63

      #3
      Thank you. I used alert and it worked!

      Comment

      • gits
        Recognized Expert Moderator Expert
        • May 2007
        • 5388

        #4
        you are welcome ... post back to the forum anytime you have more questions

        kind regards

        Comment

        Working...