PDA

View Full Version : onClick document.getElementById('B+row-number').innerHTML


Jerome
04-03-2003, 03:29 PM
Hi,

Difficult to explane, but i'll give it a try:

I have a table with one or more rows and 2 columms, one row looks like this:

<tr id="row-number" onClick=""><td id="a-columm+row-number">some data</td><td id="b-columm+row-number">data used for the onClick event</td></tr>

Every row has an id which is the row-number
Every cell has an id which is columm a or b + row-number

This works fine!

My question is:

The onClick event in the - tr - needs to have the data from columm - b - from the same row.

F.e.

<tr id="4" onClick="alert('DATA FROM CELL B4: JEROME')"><td id="A4">some data</td><td id="B4">JEROME</td></tr>

Unfortunately, the easiest way, implement the onClick event in the - td tag - from columm - b - is not possible.

Another idea, to write the data from columm - b - directly in the onClick event when building the table is also no option.

Feels like i'am running out of idea's today....
Thanks for Your effort,
Jerome

Jerome
04-04-2003, 01:48 PM
This is NOT the way to go, so I didn't.........

Jerome

Mr J
04-04-2003, 11:13 PM
Is the following any good?



<table border="1">
<tr id="row1" onClick="alert(cb_row1.innerText)">
<td id="ca_row1">Data Data Data Data</td><td id="cb_row1">Information in Row 1 Column b</td>
</tr>
<tr id="row2" onClick="alert(cb_row2.innerText)">
<td id="ca_row2"> Data Data Data</td><td id="cb_row2">More Data in Row 2 Column b</td>
</tr>
</table>

cheesebagpipe
04-09-2003, 12:14 AM
<html>
<head>
</head>
<body>
<table align="center" cellspacing="3" border="1" style="cursor:pointer;cursor:hand;">
<tr id="R4" onclick="alert(this.lastChild.firstChild.nodeValue)">
<td id="A4">some data</td><td id="B4">JEROME</td>
</tr>
</table>
</body>
</html>

http://www.brainjar.com/dhtml/intro/default.asp :cool: