Page 1 of 1

Set a JS variable onMouseover (bit more complex than that)

Posted: Sun Jul 25, 2004 12:35 pm
by Chris Corbyn
Hi,

I'm writing a page with a table on it and when you hover on certain cells the borders change in other cells depending on whcih cell you hover over.

All the cells in the table have element ID's and I've got two functions - renderOutline() [for my mouseover] and restoreOutline() [for my mouseout]. The function renderOutline takes the cell ID and sets various CSS attributes to make a shaped outline between a group of cells.
restoreOutline() does the reverse.

If that made no sense it doesn't really matter becasue all I need to do is somehow set a variable (the cell ID that the mouse most recently hovered over) somewhere. I need this so that the last view shown sticks when the mouse is no longer inside the table by using the renderOutline() function but replacing cell ID with whatever the variable is set at.

I tried making a function and adding it to my mouseovers but it doesn't seem to overwrite what ever the first variable was set to.

Code: Select all

function memVar(cell_id) {
   memVar = cell_id
   return memVar
}
memVar = memVar(cell_id)
then I added in my mouseovers....

<td id="td1" onMouseover="memVar('td1'); renderOutline('td1')" onMouseout="restoreOutline()">

Just seems to always display the outline for the first mouseover when called into renderOutline(memVar)

Am I doing this right? Maybe there is a better way to do this.

Thanks in advance :-)

Posted: Sun Jul 25, 2004 1:21 pm
by Chris Corbyn
Sorry guys problem solved... just me being stupid. Don't use JS much and I never realised you could assign vriables directly within the event handlers.

onMouseover="renderOutline('td1'); memVar='td1'" onMouseout="restoreOutline()"