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
    Jan 2006
    Posts
    243
    Thanks
    14
    Thanked 2 Times in 2 Posts

    replacing a table?

    Is it possible to delete a table and put another one in it's place, in the same document?

  • #2
    Senior Coder
    Join Date
    Mar 2005
    Location
    Portsmouth UK
    Posts
    4,536
    Thanks
    3
    Thanked 513 Times in 500 Posts
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
        "http://www.w3.org/TR/html4/loose.dtd">
    
    <html>
    
    <head>
      <title></title>
    <script language="JavaScript" type="text/javascript">
    <!--
    
    function Swap(id1,id2){
     var obj1=document.getElementById(id1);
     var obj2=document.getElementById(id2);
     var t=obj2.removeChild(obj2.getElementsByTagName('TABLE')[0]);
     obj1.appendChild(t);
     var t=obj1.removeChild(obj1.getElementsByTagName('TABLE')[0]);
     obj2.appendChild(t);
    }
    //-->
    </script>
    </head>
    
    <body>
    <input type="button" name="" value="Swap" onclick="Swap('One','Two');" >
    
    <div id="One" >
    <table width="200" border="1">
      <tr>
        <td>Table 1</td>
      </tr>
    </table>
    
    </div>
    <br>
    <br>
    <br>
    <div id="Two" style="position:absolute;visibility:hidden;" >
    <table width="200" border="1">
      <tr>
        <td>Table 2</td>
      </tr>
    </table>
    </div>
    </body>
    
    </html>
    Vic

    God Loves You and will never love you less.

    http://www.vicsjavascripts.org/Home.htm

    If my post has been useful please donate to http://www.operationsmile.org.uk/

  • #3
    Regular Coder
    Join Date
    Jan 2006
    Posts
    243
    Thanks
    14
    Thanked 2 Times in 2 Posts
    Awesome, thanks a lot!


  •  

    Posting Permissions

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