• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Geting a Cell Content Value

 
Ranch Hand
Posts: 2211
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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:

 
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 2211
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 2211
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
reply
    Bookmark Topic Watch Topic
  • New Topic