This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
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: 63208

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] [Bear's FrontMan] [About Bear] [Books by Bear]
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link:
subject: select a row in table
It's not a secret anymore!