Web Analytics Made Easy -
StatCounter Is there a way to fill a cell with JS? - CodingForum

Announcement

Collapse
No announcement yet.

Is there a way to fill a cell with JS?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Is there a way to fill a cell with JS?

    Hi there is there a way to fill the content of a cell via Java Script?

    What I want to do is to put a diferent Text (label) on a table's cell deppending in which button the user press.

    I don't know some thing like:

    document.TableName.CellName.InnerValue = "The new title";

    if there is an instruction or a way to do it please tell me.

    any help will be usefull, thanx!.

  • #2
    The .InnerValue property isn't well-supported; try this:
    Code:
    <html>
    <head>
    <title>untitled</title>
    <style type="text/css">
    
    table {
    width: 100px;
    text-align: center;
    padding: 3px;
    border: 3px coral ridge;
    background: tan;
    }
    
    td {
    font: 600 14px "Comic Sans MS";
    color: #660000;
    }
    
    input {
    font: 200 12px "Comic Sans MS";
    background: beige;
    border-color: tomato;
    }
    
    body {
    text-align: center;
    margin-top: 100px;
    background: black;
    }
    
    </style>
    <script type="text/javascript" language="JavaScript">
    
    function put(id, sContent) {
    if (typeof document.getElementById != 'undefined' && sContent)
    document.getElementById(id).innerHTML = sContent;
    }
    
    </script>
    </head>
    <body>
    <table>
    <tr>
    <td id="cell1">cell 1</td>
    </tr></table>
    <br><br>
    <form>
    <input type="button" value="Tom" onclick="put('cell1',this.value)"><hr width="100">
    <input type="button" value="Dick" onclick="put('cell1',this.value)"><hr width="100">
    <input type="button" value="Harry" onclick="put('cell1',this.value)">
    </form>
    </body>
    </html>

    Comment


    • #3
      works perfectly !!!
      thanx!!!

      Do you know where I can found a manual for the JS standard you use, you know the one with "getElementById" and stuff?

      I learn JS before it and I have read that that standard is becoming somwe kind of world convention, so I want to update my knoledge


      thanx

      Comment


      • #4
        Do yourself a favor, start at the top:

        http://www.oreillynet.com/pub/a/java.../flanagan.html

        Comment


        • #5
          This code does it too...

          http://www.codingforum.net/showthrea...=5453#post5453

          Comment

          Working...
          X