This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

select a row in table

 
Pradeep Adibatla
Ranch Hand
Posts: 336
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How is the user selecting the row? SOunds like you need a checkbox and/or onclick.

Eric
 
Pradeep Adibatla
Ranch Hand
Posts: 336
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes Eric...my 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...

row=document.getElementById("TR");

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
Marshal
Pie
Posts: 64629
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic