Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Jun 2002
    Location
    Round Rock, Texas
    Posts
    443
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question How to pass <table> back to parent

    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.
    Code:
    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()
    Last edited by RadarBob; 10-17-2002 at 07:30 PM.

  • #2
    Senior Coder
    Join Date
    Aug 2002
    Posts
    3,467
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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 can help you determine this.
    My Site | fValidate | My Brainbench | MSDN | Gecko | xBrowser DOM | PHP | Ars | PVP
    “Minds are like parachutes. They don't work unless they are open”
    “Maturity is simply knowing when to not be immature”

  • #3
    Regular Coder
    Join Date
    Jun 2002
    Location
    Round Rock, Texas
    Posts
    443
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •