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

Posted by Markus Ernst on 10/19/06 10:32

toffee schrieb:
> Steve - apologies for not making it clearer, but when a user clicks on a
> cell the page is indeed refreshed; i just wanted to be able to show which
> cell caused the refresh by highlighting it.

So you are actually submitting some info along with the refresh to tell
the script what data it has to display below the table. I assume that
this info is also available when generating the table cell - otherwise
you are not able to submit it at all. (An URL to your example would
actually be very helpful for clarifying what you actually want to do.)

Now I don't think that any X and Y values are needed. Let's assume the
info is an item number, then your table generation code will contain
something like this at the moment:

<?php foreach ($rows as $row) { ?>
<tr>
...
<td>
<a href="my_script.php?item_nr=<?php echo $row['item_nr']; ?>">
Click here for info about item nr. <?php echo $row['item_nr']; ?>
</a>
</td>
...
</tr>
<?php } ?>

In order to highlight the cell last clicked on, you evaluate the
transmitted info, and if it corresponds with the current item nr you
assign a class to the td:

<?php
foreach ($rows as $row) {
if (isset($_GET['item_nr']) && $_GET['item_nr'] == $row['item_nr'])
$class = 'highlight';
else
$class = 'standard';
?>
....
<td class="<?php echo $class; ?>">

Then you style the highlight class with CSS.

If you want to use Javascript instead, as many suggest, you should
consider to drop page refreshing at all by
- either outputting all info boxes in divs with display:none, and change
them to display_block when the cell is clicked
- or use Ajax to retrieve the info when the cell is clicked.

For both ways you can include changing the cell background in the
function that you call on Click. Both also need extra coding effort to
make the page useable for non-Javascript browsers.

--
Markus

 

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

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