HTML table mouseover events?

vu pham vu
Sat Jun 16 22:09:15 PDT 2007


On Sat, 2007-06-16 at 19:27 -0700, Net Llama! wrote:
> I'm writing a (relatively trivial) web app in PHP, which generates a
> large HTML table (15 columns, 35 rows).  Much of the content in the
> table is dynamically populated from a PostgreSQL database.
> 
> The basic functionality works fine, and I'm trying to spruce up the
> look & feel at this point.  One of the things that I'd like to do is
> add a mouseover effect, such that the row & column where the mouse
> pointer is hovering gets highlighted in a different color, kind of
> like a cross hair.  I've googled quite a bit (as my javascript skillz
> are just about non-existent), and found a few promising examples.
> However, they all fail to work in one way or another.  One of them
> only ends up highlighting the non-dynamic content in the table.
> Another requires me to set a unique ID for every cell in the table,
> which is just crazy (especially when they're getting dynamically
> generated).
> 
> Has anyone done this sort of thing before?

I have not much javascript experience, but I did somewhat similar thing.
What I did is to have each cell a span component. This component on its
turn has the property onmouseover=myprocess(this). When myprocess is
called, it uses this to know which span/cell is processed and sets the
appropriate CSS class value to that span/cell.

Vu






More information about the Linux-users mailing list