error message "object required"

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • andersond
    New Member
    • Feb 2007
    • 110

    error message "object required"

    On a webpage that has a variety of questions I get an "object required" error on lines like this...

    Code:
    document.getElementById('tableQuestion17').style.visibility="visible";
    This is the code for the table "tableQuestion1 7"

    Code:
    <table border="0" width="100%" id="tableQuestion17" cellpadding="0" style="visibility:hidden">
                <tr>
                      <td bgcolor="#003300" style="padding-right: 5px" width="55%">
                      <p align="right"><b>
                      <font color="#FFFFFF" size="2" face="Arial Narrow">Specify 
                      other method:</font></b></td>
                      <td width="45%" style="border: 1px solid #003300; padding-left: 3px; padding-top: 3px; padding-bottom: 3px">
                     <input type="text" name="otherMethod" id="otherMethod" onChange="Javascript:question('17')" size="60" style="border: 1px solid #003300; font-family:Arial Narrow; font-size:10pt; color:#000080;" tabindex="-1" ></td>
                    </tr>
              </table>
    I really don't get it. Why does javascript not accept this object?
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    Where does this line get called?

    Comment

    • andersond
      New Member
      • Feb 2007
      • 110

      #3
      onChange="javas cript:question( '17')"

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        OK, can you post the question() function code.

        Comment

        • andersond
          New Member
          • Feb 2007
          • 110

          #5
          The entire function is over 1200 lines; and, I know you don't really want that, here is the portion in question

          Code:
          function question(x){
           
           if(x=="17"){// describe the 'other' method
             document.getElementById('tableCompletionFeedback').background="../Images/completionBLUE51%25.jpg";
             document.getElementById('percent').style.fontFamily="Arial Narrow"; 
             document.getElementById('percent').style.fontSize="10pt";
             document.getElementById('percent').align="right";
             document.getElementById('percent').innerHTML="51% complete"; 
             document.getElementById('tableQuestion18').swapNode(document.getElementById('tableRow3'));
             document.getElementById('tableQuestion18').style.visibility="visible";
             document.getElementById('tableQuestion18').id="item3";
             document.getElementById('cellOutput17').style.fontFamily="Arial Narrow"; 
             document.getElementById('cellOutput17').style.fontSize="10pt"; 
             document.getElementById('cellOutput17').innerHTML="Valuation method is: "+rtrim(document.getElementById('otherMethod').value);
             document.getElementById('coinsurance').focus();
             }
          }

          Comment

          • acoder
            Recognized Expert MVP
            • Nov 2006
            • 16032

            #6
            There's no swapNode method. Have you added it via prototype?

            Comment

            • andersond
              New Member
              • Feb 2007
              • 110

              #7
              REL object required

              Trust me the problem is within the code I have already posted. But just for good measure, here's swapNode, which is a function I have used time and again.

              Code:
              <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
              <title>Vacant Buildings Submission Manager</title>
              <script type="text/javascript; version=1.5">
              Node.prototype.swapNode = function (node) {
                var nextSibling = this.nextSibling;
                var parentNode = this.parentNode;
                node.parentNode.replaceChild(this, node);
                parentNode.insertBefore(node, nextSibling);
                }  
              </script>

              Comment

              • andersond
                New Member
                • Feb 2007
                • 110

                #8
                I should also mention that it displays the error message but it still performs the function as it is supposed to do.

                Comment

                • acoder
                  Recognized Expert MVP
                  • Nov 2006
                  • 16032

                  #9
                  Originally posted by andersond
                  But just for good measure, here's swapNode, which is a function I have used time and again.
                  which does answer my question - you added it via prototype.

                  The error message makes me think it's in IE. Have you tried other browsers for something more useful?

                  Comment

                  • andersond
                    New Member
                    • Feb 2007
                    • 110

                    #10
                    FireFox gets so bogged down with "object has no properties" messages that it crashes before it ever gets to this point. But, it has to work in IE. Our website tracking software says that every one of our clients uses IE.

                    Comment

                    • acoder
                      Recognized Expert MVP
                      • Nov 2006
                      • 16032

                      #11
                      It can work in both, or more precisely, most (if not all) browsers with a little careful thinking to leave no-one out and avoid losing visitors.

                      Do you have a link? To pinpoint the problem, you need to find the exact lines and more useful error messages. IE is quite bad at line numbers. You may also find a debugger such as Firebug useful.

                      Comment

                      Working...