Results 1 to 2 of 2

Thread: How to change the text of a table cell with DHTML

  1. #1
    Guest

    Wink

    Hi there, I would like to get the proper syntax to change the text value of a cell wihtin a table. I was thinking that I could do it like this but it didn't quite work:

    <table id="mytable" border="1" cellspacing="1" width="500"
    <tr>
    <td id="A1" width="50" align="center" text="Monday"></td>
    <td id="A2" width="50" align="center" text="Tuesday"></td>
    <td id="A3" width="50" align="center" text="Wednesday"><td>
    </tr>
    </table>

    <input id= buton1 type="button" value="change Day">


    sub button1_onclick()
    mytable.cells.item(A1).style.text = "Saturday"
    end sub

    I know the above syntax isn't quite right but if you understand what I'm trying to do, please send your suggestions for a better way to do it.


  2. #2
    Frenzied Member monte96's Avatar
    Join Date
    Sep 2000
    Location
    Somewhere in AZ
    Posts
    1,379
    Code:
    <HTML>
    <HEAD>
    <SCRIPT language="vbScript">
    <!--
    Sub button1_onclick
        mytable.cells.item("A1").innertext = "Saturday" 
    End Sub 
    -->
    </SCRIPT>
    </HEAD>
    <BODY>
    <TABLE id="mytable" border="1" cellspacing="1" width="500" 
        <TR> 
            <TD id="A1" width="50" align="center">Monday></TD>
            <TD id="A2" width="50" align="center">Tuesday></TD>
            <TD id="A3" width="50" align="center">Wednesday><td>
        </TR>
    </TABLE>
    <INPUT id=button1 type="button" value="Change Day">
    </BODY>
    </HTML>
    You were close...

    oOOo--oOOo
    __/\/\onte96
    oOOo--oOOo
    Senior Programmer/Analyst
    MCP
    [email protected]
    [email protected]


    Your results may vary.. some restrictions may apply.. pricing and participation may vary.. not available in all states.. professional driver closed course..quantities limited..

Posting Permissions

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



Click Here to Expand Forum to Full Width