File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes selecting dynamically generated rows of a table Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "selecting dynamically generated rows of a table" Watch "selecting dynamically generated rows of a table" New topic
Author

selecting dynamically generated rows of a table

Pradeep Adibatla
Ranch Hand

Joined: Oct 27, 2009
Posts: 336
Hi All,

I have a table whose rows and it's values are obtained from DB...

Now I should be able to select a row from table which I am unable to achieve...

This is how the code looks like...







The values are getting displayed in the UI and on any row click I should highlight that row ...

For that I have a ChangeColor function as...





What should be the way to achieve it? I think my TR is wrong...correct me..
Shailesh Narkhede
Ranch Hand

Joined: Jul 10, 2008
Posts: 368
Hi Pradeep ,

first parmeter to ChangeColor method should be tr element object,
that can be done by passing this as first parameter.

Hope this will help.


Thanks,
Shailesh
Pradeep Adibatla
Ranch Hand

Joined: Oct 27, 2009
Posts: 336
The problem is all the rows would have same id ,if I give something like id="tRow"

all rows should have different id so I gave like that ...how else can I call that Changecolor function??
Shailesh Narkhede
Ranch Hand

Joined: Jul 10, 2008
Posts: 368

call "selectColor(this)" onclick of tr
try this
Pradeep Adibatla
Ranch Hand

Joined: Oct 27, 2009
Posts: 336
you can see in my code that TR's are dynamically generated...

Shailesh Narkhede
Ranch Hand

Joined: Jul 10, 2008
Posts: 368



use onclick="ChangeColor(this,true)" instead of onclick="ChangeColor('<%= j+1%>',true)"
Pradeep Adibatla
Ranch Hand

Joined: Oct 27, 2009
Posts: 336
Hey thanks mate! It's done.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: selecting dynamically generated rows of a table