Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
Sheriffs:
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Joe Ess
  • salvin francis
  • fred rosenberger

Geting a Cell Content Value

 
Ranch Hand
Posts: 1963
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can I get the value of a cell when I click on its contents? I want to copy this value to another text box.

This is how I populate the table on my form:

 
Marshal
Posts: 67339
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From the Help Yourself Kiosk(tm):

1) How do you detect the click on the <td>?

2) Once detected, how would you get a reference to the clicked element?

3) Once you have the refernce, how do you get its content?
 
Steve Dyke
Ranch Hand
Posts: 1963
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I am reading your post correctly I need ssome help for all three of these questions you have asked me. Where do I put the onclick, how does javascript use DOM to identify the actual cell, assign cell value to another control.

I am not sure this is what you asked or needed from me.
 
Bear Bibeault
Marshal
Posts: 67339
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Right, so you've determined that an onclick handler is needed. Where do you put it? Well, what element do you want to be sensitive to the click?
 
Steve Dyke
Ranch Hand
Posts: 1963
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
While I was waiting on your reply I modified my code some. I hope I am heading in the right direction.

I can't seem to post the code. Get error about using "<" which I had before and it posted okay. Anyway I am using scriplet to give each row and cell a dynamic id. Then I do an onclick on the cell to get the id and onclick on the row to get row id. Then I use these values on the table id to get the innerHTML contents of that coordinate.

Does this sound right?
 
Bear Bibeault
Marshal
Posts: 67339
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are wanting to get the content of a cell upon clicking it, why would you need a handler on the row?
 
Good night. Drive safely. Here's a tiny ad for the road:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!