Identifying which cell your mouse is over in a table bound to a recordset 
Author Message
 Identifying which cell your mouse is over in a table bound to a recordset

I am trying to determine which cell of a table I am over when using a
table thats bound to a recordset. In other words, the table is defined
<TABLE datasrc="#rsArecordset id=tblDataTable>.  (And, of course,
there is a <THEAD> and <TBODY> as part of this table definition).
After binding a recordset to this table, I want to mouseover (or
mouseclick) on a cell in this table and determine row/column
information.  Any ideas?  Any help would be greatly appreciated.

I've tried actually (forgetting binding the recordset to the table)
building the HTML manually (I read the recordset and for each row, I
insert a <TR> and a bunch of <TD>'s for field in that row.  Then I
inserted a unique ID for each <TD>. The table could have up to 2000
cells. It worked, but it took A LONG TIME to load.  And, I still
couldn't figure out how to do the cell identification without
providing (up to) 2000 "tdCellxx_mouseclick" event handlers. I expect
that the solution involves determining coordinates (like, pixel
coordinates) and then figuring out which cell is in that coordinate
area, but, this sounds WAY too complicated.  Again, any ideas would be
appreciated

Thanks - rich



Wed, 11 May 2005 00:26:55 GMT  
 Identifying which cell your mouse is over in a table bound to a recordset
I think you want row/cell index. Then set global event or table level event.
e.g. <body onclick="test">. Now the event code should be something like
this.

sub test
set e= window.event.srcElement
if e.tagname="TD" then
msgbox e.parentnode.rowindex & "," & e.cellindex
end if
end sub

rowIndex is the index of rows collection in a table, and cellindex is the
index of cells collection in a row.
--
Han Pohwan, Microsoft MVP, Seoul, Korea
Mail with any alphabets in the title will be removed. Use only numbers.

Quote:
> I am trying to determine which cell of a table I am over when using a
> table thats bound to a recordset. In other words, the table is defined
> <TABLE datasrc="#rsArecordset id=tblDataTable>.  (And, of course,
> there is a <THEAD> and <TBODY> as part of this table definition).
> After binding a recordset to this table, I want to mouseover (or
> mouseclick) on a cell in this table and determine row/column
> information.  Any ideas?  Any help would be greatly appreciated.

> I've tried actually (forgetting binding the recordset to the table)
> building the HTML manually (I read the recordset and for each row, I
> insert a <TR> and a bunch of <TD>'s for field in that row.  Then I
> inserted a unique ID for each <TD>. The table could have up to 2000
> cells. It worked, but it took A LONG TIME to load.  And, I still
> couldn't figure out how to do the cell identification without
> providing (up to) 2000 "tdCellxx_mouseclick" event handlers. I expect
> that the solution involves determining coordinates (like, pixel
> coordinates) and then figuring out which cell is in that coordinate
> area, but, this sounds WAY too complicated.  Again, any ideas would be
> appreciated

> Thanks - rich



Wed, 11 May 2005 01:30:17 GMT  
 Identifying which cell your mouse is over in a table bound to a recordset


Quote:
> I am trying to determine which cell of a table I am over when using a
> table thats bound to a recordset. In other words, the table is defined
> <TABLE datasrc="#rsArecordset id=tblDataTable>.  (And, of course,
> there is a <THEAD> and <TBODY> as part of this table definition).
> After binding a recordset to this table, I want to mouseover (or
> mouseclick) on a cell in this table and determine row/column
> information.  Any ideas?  Any help would be greatly appreciated.

> I've tried actually (forgetting binding the recordset to the table)
> building the HTML manually (I read the recordset and for each row, I
> insert a <TR> and a bunch of <TD>'s for field in that row.  Then I
> inserted a unique ID for each <TD>. The table could have up to 2000
> cells. It worked, but it took A LONG TIME to load.  And, I still
> couldn't figure out how to do the cell identification without
> providing (up to) 2000 "tdCellxx_mouseclick" event handlers. I expect
> that the solution involves determining coordinates (like, pixel
> coordinates) and then figuring out which cell is in that coordinate
> area, but, this sounds WAY too complicated.  Again, any ideas would be
> appreciated

> Thanks - rich

<TABLE ONMOUSEOVER="VBScript:MouseOverEventHandlerHere">

</TABLE>

Sub MouseOverEventHandlerHere()
  MsgBox TypeName(Window.Event.srcElement)
End Sub



Wed, 11 May 2005 01:40:10 GMT  
 Identifying which cell your mouse is over in a table bound to a recordset

Here's one approach using a hyperlink in each cell:

<html>
<head>
<title>pickcell.htm</title>
<script language="javascript" type="text/javascript">
<!--
function whichCell(cell) {
    alert(cell);

Quote:
}

function buildTable(row,col) {
    var tbl = "<table border='1' width='80%'>\n";
    for (var i=1; i<row+1; i++) {
        tbl += "<tr>\n";
        for (var j=1; j<col+1; j++) {
 //         tbl += "<th id='r" + i + "c" + j + "'>" + i + "," + j + "</th>\n";
            tbl += "<th><a href='javascript:whichCell(\"r" + i + "c" + j + "\")'>" + i + "," + j + "</a></th>\n";
        }
        tbl += "</tr>\n";
    }
    tbl += "</table>\n";
    document.write(tbl);
Quote:
}

// -->
</script>
<style type="text/css">
 a { text-decoration:none }
</style>
</head>
<body>
<center>
<script language="javascript" type="text/javascript">
<!--
 buildTable(99,9);
// -->
</script>
</center>
</body>
</html>


Wed, 11 May 2005 01:39:25 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Identify grid cell on mouse button 2 ?

2. DHTML binding recordset to table in VB code

3. Bind a recordset to an HTML table

4. Identify dynamic images on cells

5. Help with identify cell reference

6. Data designer bound controls seem to lose their binding to the recordset with Requery

7. Finding a record in a Bound recordset (bound using the DataEnvironment)

8. Data designer bound controls seem to lose their binding to the recordset with Requery

9. Finding a record in a Bound recordset (bound using the DataEnvironment)

10. How do I bind columns from several tables to one bound control in VB 5.0

11. Retaining styles in table cells when deleting table

12. What cell am I in?

 

 
Powered by phpBB® Forum Software