We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

trying to get the value of HTML table row data when i click button in that table row ...

Any help in the right direction, is greatly appreciated, Thank you in advance.
Here's my code to fetch data from MYSQL Database using PHP ---------------
$.getJSON("BeckysCars_load_automobile_data.php", function(data) {
$.each(data, function(index, data) {
//$("#automobile_body_content").append('');
$("#automobile_body_content").append('
');
//$("#automobile_body_content").append('
');
$("#automobile_body_content").append('
');
//$("#automobile_body_content").append('
');
$("#automobile_body_content").append('
');
$("#automobile_body_content").append('
');
$("#automobile_body_content").append('
');
$("#automobile_body_content").append('
');
$("#automobile_body_content").append('
');
$("#automobile_body_content").append('
');
$("#automobile_body_content").append('
');
$("#automobile_body_content").append('
');
$("#automobile_body_content").append('
');
$("#automobile_body_content").append('
');
$("#automobile_body_content").append('
');
//$("#automobile_body_content").append('
'+data.c_logoContent+''+data.c_name+''+data.c_url+''+data.c_email+''+data.c_phonenum+''+data.c_faxnum+''+data.c_address+''+data.c_city+''+data.c_state+''+data.c_zipcode+''+data.c_country+'
');
});
});
------- This is my layout where my data will be displayed in the tbody section -----------

Automobile Businesses

CompanyEmailPhone#Fax#AddressCityStateZipcodeCountryHiringCoupons
-------- When button is clicked in that row, i want to view the data for that row ------------
$(".coupon_button").on('click',function(){
var arrData = [ ];
// loop over each table row (tr)
$("#myAutoTable").each(function(){
var currentRow = $(this);
var col0_value = currentRow.find("td:eq(0)").text();
var col1_value = currentRow.find("td:eq(1)").text();
var col2_value = currentRow.find("td:eq(2)").text();
var col3_value = currentRow.find("td:eq(3)").text();
var col4_value = currentRow.find("td:eq(4)").text();
var obj = { };
obj.col0 = col0_value;
obj.col1 = col1_value;
obj.col2 = col2_value;
obj.col3 = col3_value;
obj.col4 = col4_value;
arrData.push(obj);
});
alert(arrData)
console.log(arrData);
});
----- if i put the "tr" in the #MyAutoTable selector i get this output -------------------
alert output:
[object Object][object Object][object Object][object Object][object Object]
console.log output:
0: {col0: "", col1: "", col2: "", col3: "", col4: ""}
1: {col0: "", col1: "", col2: "", col3: "", col4: ""}
2: {col0: "", col1: "", col2: "", col3: "", col4: ""}
3: {col0: "", col1: "", col2: "", col3: "", col4: ""}
4: {col0: "", col1: "", col2: "", col3: "", col4: ""}
5: {col0: "", col1: "", col2: "", col3: "", col4: ""}
length: 6
----- But if i remove the "tr" from the #MyAutoTable selector i get this output, but every button press gives me the same data ------------------
alert output:
[object Object]
console.log output:
col0: "Becky's Cars"
col1: "me@gmail.com"
col2: "678-789-9000"
col3: "678-789-9001"
col4: "34 West 29th street"
__proto__: Object
length: 1

1 Reply

VK Vinoth Kumar Sundara Moorthy Syncfusion Team July 2, 2019 08:58 AM UTC

Hi Mike,  
 
Good day to you. 
 
We have checked your code and we found that there are no Syncfusion controls used in your code. However, we suggest you refer the following links for your requirement.  
 
   
  
  
We suspect that you need to display some set of data in a table format. If so, you can achieve this with Syncfusion Grid control. Please refer to the following demo and UG links 
 
  
  
Could you please check the above details and get back to us if you need further assistance to proceed with Syncfusion controls? 
 
Regards, 
Vinoth Kumar S 


Loader.
Live Chat Icon For mobile
Up arrow icon