This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes HTML, CSS and JavaScript and the fly likes Getting the TD value using JavaScript + TD does not contain any ID. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Getting the TD value using JavaScript + TD does not contain any ID. " Watch "Getting the TD value using JavaScript + TD does not contain any ID. " New topic
Author

Getting the TD value using JavaScript + TD does not contain any ID.

Jigar Naik
Ranch Hand

Joined: Dec 12, 2006
Posts: 755
Hi,

I have below table



In the table there are 2 TD tags. The first tag contains the some text value which is number(111,222,333 as displayed in the table), and the second TD contains the checkbox. Now when i click on the checkbox checkboxClicked() function of java script gets called. Now i want to retrieve the value of corresponding first TD's value in the checkboxClicked function. like, when the user click on last checkbox checkboxClicked(3) will be called passing 3 as an argument. and in the checkboxClicked function i want to get the value 444. How do i achieve this ?

Is is possible ? can anybody help me out.

Below is my checkboxClicked function



This table is auto generated by some framework and i have only got the checkboxClicked function to get the data from table.


Jigar Naik


vijin das
Ranch Hand

Joined: Jun 07, 2010
Posts: 129

TRY THIS



Even if you are dynamically generating teh values 111 2222 etc write the same value as the value property of the Hidden element ..

just give a try and test it ....


VIJINDAS
Jigar Naik
Ranch Hand

Joined: Dec 12, 2006
Posts: 755
No actually the whole table is getting generated dynamically. so i can not change anything in the table. As i don't have access to the code which generate the table dynamically, its a framework. If i change the framework for my requirement so many other forms will give errors.
vijin das
Ranch Hand

Joined: Jun 07, 2010
Posts: 129

Jigar Naik wrote:No actually the whole table is getting generated dynamically. so i can not change anything in the table.

ok then whether the values 111 222 333 444 are only there ..or will it change on any circumstances ?..
Jigar Naik
Ranch Hand

Joined: Dec 12, 2006
Posts: 755
ya they will change whenever the page is loaded, basically they are coming from the database.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6



Eric
Jigar Naik
Ranch Hand

Joined: Dec 12, 2006
Posts: 755
Thanks a lot Eric, it worked.



Thanks vijin
 
wood burning stoves
 
subject: Getting the TD value using JavaScript + TD does not contain any ID.