473,385 Members | 1,720 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Error using Javascript

Hi all,

I am trying to append a TABLE element (being created dynamically) to an existing DIV element in a HTML document. But when trying to do so it is giving me the following error:

Line: 141
Char: 5
Error: Unexpected call to method or property access.
Code: 0
URL: http://localhost:8080/TreeViewer/tree_dyna_data.jsp


The javascript that I used for doing this task is as follows:

Expand|Select|Wrap|Line Numbers
  1. function addChildNode(httpRequest,node)
  2. {
  3.     if(httpRequest.readyState == 4){
  4.         if(httpRequest.status == 200){
  5.             var xmlText = httpRequest.responseText;
  6.             var xmlDom = getXmlDocument(xmlText);
  7.             var error = xmlDom.getElementsByTagName("error").item(0);
  8.             if(error==null){
  9.                 alert("in addChildNode()");
  10.                 var theDiv = node.nextSibling;
  11.                 theDiv.style.display="block";
  12.                 alert(theDiv.style.display);
  13.                 var theTable = document.createElement("table");
  14.                 var theTbody = document.createElement("tbody");    
  15.  
  16.                 //Code that will retrieve the list of file names that are returned from the server and adds them to this node.
  17.                 var fileList = xmlDom.getElementsByTagName('F');
  18.                 for(var i=0;i<fileList.length;i++){
  19.                     var theRow = document.createElement("tr");
  20.                     var fileType = fileList[i].childNodes[2].firstChild.nodeValue;
  21.                     var theTypeCell= document.createElement("td");
  22.                     theTypeCell.innerHTML="<input type=\"hidden\" value=\""+fileList[i].childNodes[2].firstChild.nodeValue+"\"></input>";
  23.                     var thePathCell = document.createElement("td");
  24.                     thePathCell.innerHTML="<input type=\"hidden\" value=\""+fileList[i].childNodes[0].firstChild.nodeValue+"\"></input>";
  25.                     var theCell = document.createElement("td");    
  26.                     if(fileType=="directory"){
  27.                         theCell.innerHTML="<a onclick=\"Toggle(this)\"><img src=\"img/plus.gif\">&nbsp;"+fileList[i].childNodes[1].firstChild.nodeValue+"&nbsp;</a><div style='display:none'></div>";
  28.                     }else{                
  29.                         theCell.innerHTML="<a onclick=\"Toggle(this)\"><img src=\"img/dot.gif\">&nbsp;"+fileList[i].childNodes[1].firstChild.nodeValue+"&nbsp;</a><div style='display:none'></div>";
  30.                     }
  31.                     theRow.appendChild(theTypeCell);
  32.                     theRow.appendChild(thePathCell);
  33.                     theRow.appendChild(theCell);
  34.                     theTbody.appendChild(theRow);
  35.                 }                            
  36.                 theTable.appendChild(theTbody);                                                    alert("DEBUG-1");
  37.                                                                 theDiv.appendChild(theTable);
  38.                                                                 alert(theDiv.nodeType);
  39.                 var prevImg = node.firstChild;
  40.                 prevImg.src="img/minus.gif";
  41.             }else {
  42.                 alert(error.firstChild.nodeValue);
  43.             }
  44.         }else{
  45.             alert("There is some problem with the request");
  46.         }
  47.     }else{        
  48.     }
  49. }
What went wrong in this code. I am clueless. I could only find that the second alert statement that is in bold is not being reached. It is executing all the code till the alert("DEBUG-1"); statement.

Any help regarding this will be verymuch helpful.

Thanks in advance,
Bluesangig
Aug 3 '07 #1
2 2264
pbmods
5,821 Expert 4TB
Heya, Bluesangig. Welcome to TSDN!

I award 12 points for creative use of [i] tags. However, I must deduct 12 points for not using [code] tags.

Better luck next time.

Please use CODE tags when posting source code. See the REPLY GUIDELINES on the right side of the page next time you post.
Aug 3 '07 #2
acoder
16,027 Expert Mod 8TB
Hi all,

I am trying to append a TABLE element (being created dynamically) to an existing DIV element in a HTML document. But when trying to do so it is giving me the following error:

Line: 141
Char: 5
Error: Unexpected call to method or property access.
Code: 0
URL: http://localhost:8080/TreeViewer/tree_dyna_data.jsp
Which line is line 141?
Aug 4 '07 #3

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

Similar topics

4
by: Geoff Cox | last post by:
Hello, One person to date has received a runtime error message saying "parent.frameleft.location is not an object" with the following code. The code is used to select 2 frames at the same...
2
by: Simon | last post by:
I have recently set up a server certificate on a web site. Under certain conditions I need to change the color of a html span element. I do this using the following javascript function called from...
1
by: Joe | last post by:
I have created a web application using C#. I have done several web based apps in C# and have not had this problem before. I think this may be a defect in the VisualSutdio.net2003. I am using a...
9
by: VancouverMike | last post by:
Hi there, I run into a very strange problem. I got the following url and am passing information via query string. The problem when the "sin" key in query string is blank, shown as in the...
8
by: Taras_96 | last post by:
Hi everyone, We' ve come to the conclusion that we wish the user to be directed to an error page if javascript is disabled <enter comment about how a webpage shouldn't rely on javascript here :)...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.