aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes Geting a Cell Content Value Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Geting a Cell Content Value" Watch "Geting a Cell Content Value" New topic
Author

Geting a Cell Content Value

Steve Dyke
Ranch Hand

Joined: Nov 16, 2004
Posts: 1479
    
    1
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:

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61662
    
  67

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?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Steve Dyke
Ranch Hand

Joined: Nov 16, 2004
Posts: 1479
    
    1
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
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61662
    
  67

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

Joined: Nov 16, 2004
Posts: 1479
    
    1
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
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61662
    
  67

If you are wanting to get the content of a cell upon clicking it, why would you need a handler on the row?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Geting a Cell Content Value