Bolineni Tiger Posted October 28, 2022 Share Posted October 28, 2022 Hi, I need help; please, can anyone help me? It is a legacy project I am doing enhancement for a page. I have one HTML page with dynamic data table rows and columns. We have one element, like a dropdown list, in each row in one of the cells. How can we get the ID of that element? I know how to get an inner text or inner HTML, but I need elements I'd because I need to do some operations on that element. Link to comment Share on other sites More sharing options...
vk_hyd Posted October 28, 2022 Share Posted October 28, 2022 Array use chestham ga..dynamic rows ante array of elements.. Link to comment Share on other sites More sharing options...
HelloNTR Posted October 28, 2022 Share Posted October 28, 2022 html structure post cheyagalara Link to comment Share on other sites More sharing options...
vk_hyd Posted October 28, 2022 Share Posted October 28, 2022 Suppose u have 10 rows and each has student which is 10 indexs.. document.getElementById(student[i]).innerHTML Link to comment Share on other sites More sharing options...
Bolineni Tiger Posted October 28, 2022 Author Share Posted October 28, 2022 19 minutes ago, HelloNTR said: html structure post cheyagalara Hmm it is simple html with 5 columns and N number of rows based on the data. In each row in 4th column added one dropdown list and button in 5th column. I am writing Java script to get element I'd of dropdowm list on button click. With that I'd , need to get selected option from dropdown. Link to comment Share on other sites More sharing options...
HelloNTR Posted October 28, 2022 Share Posted October 28, 2022 42 minutes ago, Bolineni Tiger said: Hmm it is simple html with 5 columns and N number of rows based on the data. In each row in 4th column added one dropdown list and button in 5th column. I am writing Java script to get element I'd of dropdowm list on button click. With that I'd , need to get selected option from dropdown. https://stackoverflow.com/questions/26999167/get-id-of-table-cell first use this to get the id of the table cell on which you clicked https://stackoverflow.com/questions/1904827/how-to-get-selected-option-id Then use this to fetch the dropdown id Sample code: <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <table id="chessboard"> <tr> <td id="A8">A8</td> <td id="B8">B8</td> <td id="C8">C8</td> <tr> <tr> <td id="A7">A7</td> <td id="B7">B7</td> <td id="C7">C7</td> <tr> <tr> <td id="A6">A6</td> <td id="B6">B6</td> <td id="C6">C6</td> <tr> </table> $("#chessboard td").on("click", function(cell){ alert(this.id); var id = this.id; var options = document.getElementById(id).options; var id = options[options.selectedIndex].id; var value = options[options.selectedIndex].value; }) Link to comment Share on other sites More sharing options...
balaaus Posted October 28, 2022 Share Posted October 28, 2022 $(this).closest('td').attr("id"); Try the above bro... $("#chessboard td").on("click", function(){ var ClicledTdId = $(this).closest('td').attr('id'); alert(ClicledTdId); }); Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.