• Post Reply Bookmark Topic Watch Topic
  • New Topic

select a row in table  RSS feed

 
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
Posts: 65833
134
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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!