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

error message "object required"

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

Expand|Select|Wrap|Line Numbers
  1. document.getElementById('tableQuestion17').style.visibility="visible";
  2.  
This is the code for the table "tableQuestion17"

Expand|Select|Wrap|Line Numbers
  1. <table border="0" width="100%" id="tableQuestion17" cellpadding="0" style="visibility:hidden">
  2.             <tr>
  3.                   <td bgcolor="#003300" style="padding-right: 5px" width="55%">
  4.                   <p align="right"><b>
  5.                   <font color="#FFFFFF" size="2" face="Arial Narrow">Specify 
  6.                   other method:</font></b></td>
  7.                   <td width="45%" style="border: 1px solid #003300; padding-left: 3px; padding-top: 3px; padding-bottom: 3px">
  8.                  <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>
  9.                 </tr>
  10.           </table>
  11.  
I really don't get it. Why does javascript not accept this object?
Jan 12 '09 #1
Share this Question
Share on Google+
10 Replies


acoder
Expert Mod 15k+
P: 16,027
Where does this line get called?
Jan 12 '09 #2

100+
P: 110
onChange="javascript:question('17')"
Jan 12 '09 #3

acoder
Expert Mod 15k+
P: 16,027
OK, can you post the question() function code.
Jan 12 '09 #4

100+
P: 110
The entire function is over 1200 lines; and, I know you don't really want that, here is the portion in question

Expand|Select|Wrap|Line Numbers
  1. function question(x){
  2.  
  3.  if(x=="17"){// describe the 'other' method
  4.    document.getElementById('tableCompletionFeedback').background="../Images/completionBLUE51%25.jpg";
  5.    document.getElementById('percent').style.fontFamily="Arial Narrow"; 
  6.    document.getElementById('percent').style.fontSize="10pt";
  7.    document.getElementById('percent').align="right";
  8.    document.getElementById('percent').innerHTML="51% complete"; 
  9.    document.getElementById('tableQuestion18').swapNode(document.getElementById('tableRow3'));
  10.    document.getElementById('tableQuestion18').style.visibility="visible";
  11.    document.getElementById('tableQuestion18').id="item3";
  12.    document.getElementById('cellOutput17').style.fontFamily="Arial Narrow"; 
  13.    document.getElementById('cellOutput17').style.fontSize="10pt"; 
  14.    document.getElementById('cellOutput17').innerHTML="Valuation method is: "+rtrim(document.getElementById('otherMethod').value);
  15.    document.getElementById('coinsurance').focus();
  16.    }
  17. }
  18.  
Jan 12 '09 #5

acoder
Expert Mod 15k+
P: 16,027
There's no swapNode method. Have you added it via prototype?
Jan 12 '09 #6

100+
P: 110
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.

Expand|Select|Wrap|Line Numbers
  1. <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
  2. <title>Vacant Buildings Submission Manager</title>
  3. <script type="text/javascript; version=1.5">
  4. Node.prototype.swapNode = function (node) {
  5.   var nextSibling = this.nextSibling;
  6.   var parentNode = this.parentNode;
  7.   node.parentNode.replaceChild(this, node);
  8.   parentNode.insertBefore(node, nextSibling);
  9.   }  
  10. </script>
  11.  
Jan 13 '09 #7

100+
P: 110
I should also mention that it displays the error message but it still performs the function as it is supposed to do.
Jan 13 '09 #8

acoder
Expert Mod 15k+
P: 16,027
@andersond
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?
Jan 14 '09 #9

100+
P: 110
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.
Jan 14 '09 #10

acoder
Expert Mod 15k+
P: 16,027
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.
Jan 14 '09 #11

Post your reply

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