473,503 Members | 1,700 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

capture click in table cell

3 New Member
Hello,

Is there a way to determine in which table cell the user clicked WITHOUT the use of <input> or <a href> IN EVERY CELL ?
It concerns over 200 cells and I like to keep my source compact.

I already asigned a differend class for each table cell for other purpoces.
Reading that class is sufficient.

But how does javacript determine in which table cell the user clicked in the first place ?

Jeroen
Aug 10 '07 #1
4 2616
bambr
3 New Member
Hello,

Is there a way to determine in which table cell the user clicked WITHOUT the use of <input> or <a href> IN EVERY CELL ?
It concerns over 200 cells and I like to keep my source compact.

I already asigned a differend class for each table cell for other purpoces.
Reading that class is sufficient.

But how does javacript determine in which table cell the user clicked in the first place ?

Jeroen
Hey there.
You can do it like this:
Expand|Select|Wrap|Line Numbers
  1. <script>
  2. function showMe(cell)
  3. {
  4.  cell.normalize();
  5.  alert(cell.parentNode.id);
  6. }
  7. </script>
  8. <td id="Cell_1"><input type="button" value="Click me" onclick="showMe(this);return false;"></td>
  9.  
Aug 10 '07 #2
jatscripts
3 New Member
And.., bambr, do you know a way to do this ".. WITHOUT the use of <input> or <a href> IN EVERY CELL ?" ... ?
Aug 10 '07 #3
bambr
3 New Member
And.., bambr, do you know a way to do this ".. WITHOUT the use of <input> or <a href> IN EVERY CELL ?" ... ?
Heh, you can put onclick handler to td itself and modify the code of handler from cell.parentNode.id to cell.id
Aug 10 '07 #4
mrhoo
428 Contributor
In IE you can attach an event handler to the document.documentElement (with a doctype) or document.body (without.) Return the window.event.srcElement.

Expand|Select|Wrap|Line Numbers
  1. document.documentElement.onclick=function(e){
  2.     return window.event.srcElement;
  3. }
The other browsers will bubble events up to the window. Return e.target,
where e is a parameter of the handler function.

Expand|Select|Wrap|Line Numbers
  1. window.onclick=function (e){
  2.     return e.target;
  3. }
Aug 10 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

2
2866
by: Carl Gilbert | last post by:
Hi I have a basic page for which I have included some of the code for at the end of this message. It may not run correctly as I have cropped out a lot of code. I am trying to handle the...
6
5387
by: chandramohan.mani | last post by:
I have table with 'n' number of rows. I want to highlight the row when ever i click on a particular row of the table. Can anyone please help me in this. Iam not using any Id's for the row. ...
1
12007
by: edself | last post by:
I have a form which displays a subform datasheet of information. I'd like to be able to quickly click on a particular record and open up another form showing more detailed information about that...
4
2429
by: simon | last post by:
which data control allows me to use a cell doubleClick event? I have time cells (something like Outlook calendar) and when user double click on one cell I would like to redirect to other window...
10
27775
by: Tim Frawley | last post by:
I am attempting to detect a Shift+Tab in the KeyPress event for back navigation on a control that doesn't support this method. Does anyone have any ideas how to compare e.KeyChar to a ShiftTab? ...
8
2558
by: Ken Sturgeon | last post by:
I have a button inside a panel control. Apparently I can't expect VB to respond to the button's _Click event. How do I capture the click event? Thanks Ken
0
2081
by: loga123 | last post by:
Hi All, I am very new to .net and trying to develop a small application. I am using asp .net 2.0. I have a table control (server) in my code that has header row like this. <asp:Table...
2
5008
by: TC | last post by:
Hello, I need to build a very simple text editor. The requirement is that the input screen should be divided into 'm*n' cells ('m' rows, 'n' columns, with each cell of a fixed size). Whenever...
9
2260
by: sumuka | last post by:
Hello , I'm doing project in vb 6 and i have a flex grid now i need to right click on the cell of a flexgrid and after right click it should open a msgbox .The problem is what should i write in...
0
7083
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
6988
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7456
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5578
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4672
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3166
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1510
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
734
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
379
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.