Currently, I am facing a challenge with looping through a table that is dynamically created using C#. I have a client-side checkbox that should trigger the loop each time it's clicked. While I believe I can manage the looping process itself, I am encountering difficulties in implementing this functionality using JavaScript.
Here is the code snippet for the checkbox:
Next, I have defined a function that is supposed to iterate through the table:
<script>
function LoopThroughTable() {
var chkState = document.getElementById("chkSelectAll");
alert(document.getElementById("fileTablePersonal").rows.length);
if (chkState.checked) {
alert("Loop through table");
} else {
alert("Loop through table again");
}
}
</script>
My current issue lies in the fact that I am unable to display the number of rows or columns by using JavaScript. Although I tried using 'rows.length', it does not seem to provide the desired output.
I would greatly appreciate any assistance regarding this matter.
Edit: It is worth mentioning that my table is generated using Asp.Net.