This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
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 OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA 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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: selecting dynamically generated rows of a table