You are here: Re: how to highlight cell « All PHP « IT news, forums, messages
Re: how to highlight cell

Posted by Moot on 10/18/06 14:15

toffee wrote:
> Hi all,
>
> I have a table with 12 cols and 10 rows. When a user clicks on a table cell;
> the page is refreshed and displays some data below the table dependant on
> whichever cell was selected.
> I would like to make it so that whichever cell was clicked; the background
> color is changed - so that when the user sees the data, (s)he can tell which
> cell it relates to.
>
> Does anyone know of a clever way to do this ?
> I'm afraid my creativity is running a bit dry on this one as the only
> working way i could come up with so far is to have an if statement before
> each table cell is created, which is long winded.
>
> kind regards
>
> T

Long winded indeed.

The only other option I can think of at the moment is keeping an array
for each cell as X,Y coordinates, and the value of the array element
would be a string like 'style="background-color:#CCCCCC;"'. Then just
reference array location for each cell and output the contents. If it
is empty, fine, but if you assign a string like that, the color will
change.

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>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация