File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes HTML, CSS and JavaScript and the fly likes select a row in table Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "select a row in table" Watch "select a row in table" New topic

select a row in table

Pradeep Adibatla
Ranch Hand

Joined: Oct 27, 2009
Posts: 336
I have a table whose rows are dynamically added...

I want to select any row and listen to that row... how to do this in Javascript?

I get the table body this way...

Now what should be done??

Eric Pascarello

Joined: Nov 08, 2001
Posts: 15385
How is the user selecting the row? SOunds like you need a checkbox and/or onclick.

Pradeep Adibatla
Ranch Hand

Joined: Oct 27, 2009
Posts: 336
yes intent is to select using click since I was denied using checkbox as per requirements...

but the problem is inside the javascript...

I create a row as...


So am always getting the current row and unable to track the previously added rows...

How to get all previously added rows and move the mouse over my table and click a row and listen to onclick??
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63838

If you establish a click handler for each row, the TR element upon which you click will be available in the Event instance passed to the handler.

[Asking smart questions] [About Bear] [Books by Bear]
I agree. Here's the link:
subject: select a row in table
jQuery in Action, 3rd edition