Hi,
I know this is not an ASP.NET question, but I thought someone might be able
to help.
I need to handle mouseover events etc for table cells. This is fine and I
can do this ok, my question is ifI can do it easier.
I have a table with hundreds of cells and I dont want to have to render the
whole table with as many onmouseover="functionName(this)" as there are
cells.
Does anyone know of a way of arranging things so that any cell mousover for
example will call the same function but send its own element to the
function. ?
Cheers
Peter Bromberg [C# MVP] - 13 Dec 2007 02:01 GMT
I'm not aware of any, although its possible somebody smarter than me may
offer a way. Basically, you have to attach the onmouseover client script
event to each element.
-- Peter
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
MetaFinder: http://www.blogmetafinder.com
> Hi,
>
[quoted text clipped - 13 lines]
>
> Cheers
bruce barker - 13 Dec 2007 04:35 GMT
you can by capturing the mouse, but then you need to walk the dom
calculating what element the mouse is over. this would be too slow.
you could attach the handlers with a simple javascript routine:
var tbl = document.getElementById('tableid');
var cells = tbl.getElementsByTagName('td');
for (var i=0; i < cells.length; ++i)
{
cells[i].onmouseover = function(){ functionName(this); };
}
-- bruce (sqlwork.com)
> Hi,
>
[quoted text clipped - 13 lines]
>
> Cheers
Just Me - 15 Dec 2007 18:12 GMT
Thanks Bruce.
Actually, I found that I can simply attach the routine to the TR element,
and then interrogate the event object to discover the srcElement.
Cheers
> you can by capturing the mouse, but then you need to walk the dom
> calculating what element the mouse is over. this would be too slow.
[quoted text clipped - 27 lines]
>>
>> Cheers