Forum Moderators: open

Message Too Old, No Replies

link row with function

call function from table row

         

Slait

4:09 pm on Oct 6, 2005 (gmt 0)

10+ Year Member



Hi,
My problem is I can't find out how to tell function that it was called from defined row in the table:

<script>
function i_was_called_from_row(Cell_content)
{
alert (Cell_content);
}

<body>
<table id="mytable">
<tr onclick="i_was_called_from_row(?)>
<td>Cell_content</td>
</tr>
</table>
So how can I pass the cell content as argument to the fuction?
Thanks

ChadSEO

4:55 pm on Oct 6, 2005 (gmt 0)

10+ Year Member



Slait,

One way of doing that would be like this:

<script>
function i_was_called_from_row(obj)
{
value = obj.cells[0].innerHTML;
alert (value);
}
</script>

<body>
<table id="mytable">
<tr onclick="i_was_called_from_row(this)">
<td>Cell_content</td>
</tr>
</table>
</body>

Slait

5:10 pm on Oct 6, 2005 (gmt 0)

10+ Year Member



Thanks ChadSEO, that's great!