Click here to Skip to main content
14,486,704 members
Rate this:
Please Sign up or sign in to vote.
i have datatable

i need to make for loop
but i have hidden column and i need to get value and set a new value

var rows = $("#containerprosCC").dataTable().fnGetNodes();

for(var i=1;i<rows.length;i++) {

alert(document.getElementById('Uint'+i).value);

}


Error
TypeError: document.getElementById(...) is null


What I have tried:

i have datatable

i need to make for loop
but i have hidden column and i need to get value and set a new value

var rows = $("#containerprosCC").dataTable().fnGetNodes();

for(var i=1;i<rows.length;i++) {

alert(document.getElementById('Uint'+i).value);

}


Error
TypeError: document.getElementById(...) is null
Posted
Updated 23-Mar-20 7:32am
v2

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

The error message is clear - your document doesn't contain an element with the ID 'Uint' + i for every row in your table.

When you pass in an ID which doesn't exist in the current document, getElementById returns null. Attempting to access a property of the returned value will throw the error that you're seeing.

You need to debug your code to find out why the elements don't exist when you think they should.
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100