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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Referencing and writing in a TABLE

Status
Not open for further replies.

saimon65

Technical User
Jan 2, 2002
16
AU
Hi all. I am trying to write something in a specific cell of a table.

I have done something like this write now.

function getCellByRowCol(rowNum, colNum)
{
var tableElem = document.getElementById ('imageBoxTbl');
var rowElem = imageBoxTbl.rows[rowNum];
var tdValue = imageBoxTbl.cells[colNum].innerHTML;
}


What I want to do is, when the user clicks a button, write a text "Finished" in the 2nd row third cell. Can anyone please tell me how to do it.

thanks.
 
Give the table cell an id (say, 'myCellID') and then use a very similar technique to the one you already use...
Code:
document.getElementById('myCellID').innerHTML = 'Finished';

Is this what you were aiming for?

Cheers,
Jeff
 
[tt]>var tableElem = document.getElementById ('imageBoxTbl');
>var rowElem = imageBoxTbl.rows[rowNum];
>var tdValue = imageBoxTbl.cells[colNum].innerHTML;[/tt]

Should be like this with the idea so presented.

[tt]var tableElem = document.getElementById ('imageBoxTbl');
var rowElem = imageBoxTbl.rows[rowNum];
var tdValue = [red]rowElem[/red].cells[colNum].innerHTML;
[/tt]
row/colNum are zero-based including header.

To assign value to it is the same.
[tt]
[red]rowElem[/red].cells[colNum].innerHTML = newvalue;
[/tt]
 
i was thinking presentation like this
Code:
var tableElem = document.getElementById ('imageBoxTbl');
[red]var rowElem = tableElem.rows[rowNum];[/red]
var tdValue = rowElem.cells[colNum].innerHTML;
then as tsuji said in the previous post. ;)

---------------------------
WORD OR VOTE TO THE WISE IS ENUFF...;)
 
That's what I had in mind too (the tableElem)! Just can't coordinate it with fingers. I agree with the further input from sirlojik.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top