Results 1 to 5 of 5

Thread: Inserting text into a table cell via second cell

  1. #1
    Join Date
    Apr 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Inserting text into a table cell via second cell

    Hi. I'm new to this and need some expert help.

    I have a table and I want to insert text into a specific cell from an external file when I hover over another cell.

    How do I do this? (I said I was new to this!)

  2. #2
    Join Date
    Sep 2005
    Location
    India
    Posts
    1,626
    Thanks
    6
    Thanked 107 Times in 107 Posts

    Default

    Are you looking for something like the following:

    Please make sure that files 2.htm and 3.htm resides on the same folder where your mainfile.htm resides

    mainfile.htm
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title>Main File</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    </head>
    
    <body>
    
    <table cellpadding="0" cellspacing="0" border="1" width="300">
    <tr>
    <td  width="150"><iframe id="one" src="2.htm" frameborder="0" style="visibility:hidden;"></iframe></td>
    <td  width="150" ><iframe id="two" src="3.htm" frameborder="0" style="visibility:hidden;"></iframe></td>
    </tr>
    <tr>
    <td width="150" onmouseover="document.getElementById('one').style.visibility='visible';" onmouseout="document.getElementById('one').style.visibility='hidden';">&nbsp;</td>
    <td width="150" onmouseover="document.getElementById('two').style.visibility='visible';" onmouseout="document.getElementById('two').style.visibility='hidden';">&nbsp;</td>
    </tr>
    </table>
    </body>
    </html>

    2.htm
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    </head>
    
    <body>
    This is a testing by CodeExploiter
    </body>
    </html>
    3.htm
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    </head>
    
    <body>
    JavaScript is cool.
    </body>
    </html>
    As this is just a demo I haven't inserted any meaningful information inside the above furnished pages.

  3. #3
    Join Date
    Apr 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thanks for the quick reply and it'll do nicely. It seems odd that it's not possible to write directly to a cell without utilising a frame - but maybe I'm missing something.

  4. #4
    Join Date
    Jul 2006
    Location
    just north of Boston, MA
    Posts
    1,806
    Thanks
    13
    Thanked 72 Times in 72 Posts

    Default

    you can, but css cannot do it. css has nothing to do with inserting data into a cell. css is used for presentation (color / structure).

  5. #5
    Join Date
    Jul 2006
    Location
    Canada
    Posts
    2,581
    Thanks
    13
    Thanked 28 Times in 28 Posts

    Default

    Code:
    <script type="text/javascript">
    var el = document.createElement("div");
    el.appendChild(document.createTextNode("Hi, my name is new div tag."))
    element.appendChild(el);
    </script>
    The DOM way of appending data.
    - Mike

Bookmarks

Posting Permissions

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