greedyzebra
Technical User
In the following code:
<html>
<head>
<style type="text/css">
.hideMe {display : none}
</style>
</head>
<body>
<table border="0" width="60%" id="theTable">
<tr>
<td width="50%"><input type="button" value="Click Here" onclick="document.getElementById('tCell1').onclick()"></td>
<td width="50%" class="hideMe" onclick="this.style.display='inline'" id="tCell1">Data for cell 1</td>
</tr>
<tr>
<td width="50%"><input type="button" value="Click Here" onclick="document.getElementById('tCell2').onclick()"></td>
<td width="50%" class="hideMe" onclick="this.style.display='inline'" id="tCell2">Data for cell 2</td>
</tr>
<tr>
<td width="50%"><input type="button" value="Click Here" onclick="document.getElementById('tCell3').onclick()"></td>
<td width="50%" class="hideMe" onclick="this.style.display='inline'" id="tCell3">Data for cell 3</td>
</tr>
<tr>
<td width="50%"><input type="button" value="Click Here" onclick="document.getElementById('tCell4').onclick()"></td>
<td width="50%" class="hideMe" onclick="this.style.display='inline'" id="tCell4">Data for cell 4</td>
</tr>
</table>
</body>
</html>
I would think that instead of having to create a separate id for each table cell in the "hideMe" class I could access what appears to be the next node in the document tree (the table cells are part of the same table row, right?).
If that doesn't make sense, I guess my question boils down to this, how can I affect the style attributes of cell 2 by clicking the button in cell 1 without having to have the unique id's for the cells not containing the button?
Thanks.
<html>
<head>
<style type="text/css">
.hideMe {display : none}
</style>
</head>
<body>
<table border="0" width="60%" id="theTable">
<tr>
<td width="50%"><input type="button" value="Click Here" onclick="document.getElementById('tCell1').onclick()"></td>
<td width="50%" class="hideMe" onclick="this.style.display='inline'" id="tCell1">Data for cell 1</td>
</tr>
<tr>
<td width="50%"><input type="button" value="Click Here" onclick="document.getElementById('tCell2').onclick()"></td>
<td width="50%" class="hideMe" onclick="this.style.display='inline'" id="tCell2">Data for cell 2</td>
</tr>
<tr>
<td width="50%"><input type="button" value="Click Here" onclick="document.getElementById('tCell3').onclick()"></td>
<td width="50%" class="hideMe" onclick="this.style.display='inline'" id="tCell3">Data for cell 3</td>
</tr>
<tr>
<td width="50%"><input type="button" value="Click Here" onclick="document.getElementById('tCell4').onclick()"></td>
<td width="50%" class="hideMe" onclick="this.style.display='inline'" id="tCell4">Data for cell 4</td>
</tr>
</table>
</body>
</html>
I would think that instead of having to create a separate id for each table cell in the "hideMe" class I could access what appears to be the next node in the document tree (the table cells are part of the same table row, right?).
If that doesn't make sense, I guess my question boils down to this, how can I affect the style attributes of cell 2 by clicking the button in cell 1 without having to have the unique id's for the cells not containing the button?
Thanks.