Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I change innerHTML on a particular row's cells in a table

Status
Not open for further replies.

DoTheLoop

Programmer
Sep 12, 2003
14
0
0
SE
Hia!

I have a question about tables and changing the contents of a particular row inside that table.

Something like this:
Code:
<table id=mytable>
  <tr>
    <td><input type=button name=foo value=click onclick=javascript:changethisrow(andthesecells);></td> 
    <td>1</td>
    <td>2</td>
    <td>3</td>
  </tr>
  <tr>
    <td>4</td>
    <td>5</td>
    <td>6</td>
  </tr>
</table>

What I want to put into those particular cells looks something like this:
Code:
<tr>
  <td><input type=text name=something_unique value=foo></td>
  <td><input type=text name=something_unique value=foo></td>
  <td><input type=text name=something_unique value=foo></td>
  <td><input type=text name=something_unique value=foo></td>
</tr>
Thanks in advance

Regards
DoTheLoop
 
put an id= on the <tr>
in the buttonclick pass the id to the javascript function
in the function, grab the object (row) using getElementById(), and set its innerHTML to the appropriate string ie all the tags for your <td>s.

 
Thanks for the help. I get right into it then.


/DoTheLoop
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top