Click here to Skip to main content
15,892,768 members
Please Sign up or sign in to vote.
1.00/5 (1 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

JavaScript
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

JavaScript
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

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.
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900