...

View Full Version : How to pass <table> back to parent



RadarBob
10-17-2002, 03:30 PM
Background
I'm spawning a child window from a parent. In the child I'm dynamically building a table. When I click "finished" I want the entire table to go back to the parent and replace the original table "shell" (an empty <table> </table> tag-pair).

Note: The table ID is the same at the parent and child. This allows the replacement to work repeatedly. The child window closes but I don't see the table on the parent.

I get the feeling I'm mixing DHTML and DOM (ie "window.opener....") and .. well, I don't know what to think.

Is it OK to nest DOM functions as shown in the code?

I've tried a couple of different things - I'd like to use "replaceNode", but the syntax is not clear in the reference I have.

[b]The problem{/b]
Below is the function triggered by the child window "finished" button's onclick event.

I suspect the variable assignment is wrong as an alert box immediately after it (removed in this sample) did not show up.


function finished() {
var oldReport = window.opener.document.getElementbyId('DBReportsTable');
oldReport.firstChild.removeNode(true); // the <tbody>
oldReport.appendChild(document.getElementById('DBReportsTable').firstChild);
window.close();
return true;
} // finished()

beetle
10-17-2002, 06:14 PM
Couple things....

removeNode() is IE only. Should change to:

oldReport.removeChild(oldReport.firstChild);

Also, is the TBODY really the firstChild? If you're browsing with Gecko, it could be a textNode.

Vladdy's kick*ss DOM Viewer (http://www.vladdy.net/WebDesign/DOM_TreeViewer.html) can help you determine this.

RadarBob
10-17-2002, 06:42 PM
Didn't realize removeNode (et.al.) is IE only. I don't recall the tutorial at Doc Javascript http://www.webreference.com/js/ saying it was IE unique.

Yes, the firstChild reference for tbody works. It just happens that tbody is the only child of table.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum