Posted by Steve on 10/18/06 16:09
| Both solutions require you to put code at each cell though...
| I've never figured out any way around it.
|
| Ex:
| <?
| $cellStyles = array();
| $cellStyles[1][0] = 'style="background-color:#CCCCCC;"';
| ?>
|
| <table>
| <tr>
| <td <?=$cellStyles[0][0]?>>a</td>
| <td <?=$cellStyles[1][0]?>>b</td>
| </tr>
| <tr>
| <td <?=$cellStyles[0][1]?>>c</td>
| <td <?=$cellStyles[1][1]?>>d</td>
| </tr>
| </table>
perhaps this may be easier (if i understood you correctly):
<html>
<style type="text/css">
td
{
background-color : white;
cursor : pointer;
width : 50px;
}
</style>
<script type="text/javascript">
var currentCell;
function colorMe(el)
{
if (!el){ return; }
if (!el.style){ return; }
if (currentCell){ currentCell.style.backgroundColor = ''; }
currentCell = el;
currentCell.style.backgroundColor = '#CCCCCC';
}
</script>
<body>
<table>
<tr>
<td onclick="colorMe(this);">a</td>
<td onclick="colorMe(this);">b</td>
</tr>
<tr>
<td onclick="colorMe(this);">c</td>
<td onclick="colorMe(this);">d</td>
</tr>
</table>
<body>
<html>
Navigation:
[Reply to this message]
|