Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • 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
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

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

 
Ranch Hand
Posts: 763
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 129
Firefox Browser Tomcat Server Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ....

 
Jigar Naik
Ranch Hand
Posts: 763
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 129
Firefox Browser Tomcat Server Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 763
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ya they will change whenever the page is loaded, basically they are coming from the database.
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator



Eric
 
Jigar Naik
Ranch Hand
Posts: 763
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot Eric, it worked.



Thanks vijin
 
Hey, sticks and stones baby. And maybe a wee mention of my stuff:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic