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
- function addChildNode(httpRequest,node)
- {
- if(httpRequest.readyState == 4){
- if(httpRequest.status == 200){
- var xmlText = httpRequest.responseText;
- var xmlDom = getXmlDocument(xmlText);
- var error = xmlDom.getElementsByTagName("error").item(0);
- if(error==null){
- alert("in addChildNode()");
- var theDiv = node.nextSibling;
- theDiv.style.display="block";
- alert(theDiv.style.display);
- var theTable = document.createElement("table");
- var theTbody = document.createElement("tbody");
- //Code that will retrieve the list of file names that are returned from the server and adds them to this node.
- var fileList = xmlDom.getElementsByTagName('F');
- for(var i=0;i<fileList.length;i++){
- var theRow = document.createElement("tr");
- var fileType = fileList[i].childNodes[2].firstChild.nodeValue;
- var theTypeCell= document.createElement("td");
- theTypeCell.innerHTML="<input type=\"hidden\" value=\""+fileList[i].childNodes[2].firstChild.nodeValue+"\"></input>";
- var thePathCell = document.createElement("td");
- thePathCell.innerHTML="<input type=\"hidden\" value=\""+fileList[i].childNodes[0].firstChild.nodeValue+"\"></input>";
- var theCell = document.createElement("td");
- if(fileType=="directory"){
- theCell.innerHTML="<a onclick=\"Toggle(this)\"><img src=\"img/plus.gif\"> "+fileList[i].childNodes[1].firstChild.nodeValue+" </a><div style='display:none'></div>";
- }else{
- theCell.innerHTML="<a onclick=\"Toggle(this)\"><img src=\"img/dot.gif\"> "+fileList[i].childNodes[1].firstChild.nodeValue+" </a><div style='display:none'></div>";
- }
- theRow.appendChild(theTypeCell);
- theRow.appendChild(thePathCell);
- theRow.appendChild(theCell);
- theTbody.appendChild(theRow);
- }
- theTable.appendChild(theTbody); alert("DEBUG-1");
- theDiv.appendChild(theTable);
- alert(theDiv.nodeType);
- var prevImg = node.firstChild;
- prevImg.src="img/minus.gif";
- }else {
- alert(error.firstChild.nodeValue);
- }
- }else{
- alert("There is some problem with the request");
- }
- }else{
- }
- }
Any help regarding this will be verymuch helpful.
Thanks in advance,
Bluesangig