I have a dataTable which I need to iterate through. so I have this code:
var tableSize = $('#j_idt11\\:dataTable tbody tr').length;
for(i = 0;i< tableSize;i++){
var test1 = document.getElementById("j_idt11:dataTable:0:updFoodType").textContent;
if(test1 == "food")
alert("hey");
}
but I really want to use the i in the for loop. I thought something like this:
var tableSize = $('#j_idt11\\:dataTable tbody tr').length;
for(i = 0;i< tableSize;i++){
var test1 = document.getElementById("j_idt11:dataTable:[i]:updFoodType").textContent;
if(test1 == "food")
alert("hey");
}
but that doesn’t work. how must I use the syntax? Thanks!
The for loop has nothing to do with it, you need to concatenate the string,
Also be careful with globals, you should declare
iin the local scope as well.