Message: 'childNodes.length' is null or not an object

Message: ‘childNodes.length’ is null or not an object

i have a function
function GridAllCheck(Grid_Name)
{
var G_View = document.getElementById(Grid_Name).id;

alert(G_View);//- here i am getting the gridview id

for(var child1 = 0; child1 <= G_View.childNodes.length-1;child1++)
{
var G_Child1 = G_View.childNodes(child1);
for(var child2 = 0; child2 <= G_Child1.childNodes.length-1;child2++)
{

}
}
}
}

i have multiple grids

An ID doesn’t have any child nodes. It looks like you don’t want G_View to be an ID, but to be an element, so remove the .id from the end. (I don’t know if that’s valid anyway.)

ok
how do i solve the issue id i dont get the id & only get the element as ]
var G_View = document.getElementById(Grid_Name);
i have multiple grids(GridView) in a page
i need a function such tht depending on the grid focused first i need to get its id
like gridview1 …
for each grid i need to get childnodes

I recommend you post a full example of what you are trying to do. Here’s a starting template:


<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
	
<style>

[COLOR="#FF0000"][I]your CSS here[/I][/COLOR]

</style>
	
</head>
<body>

[COLOR="#FF0000"][I]your HTML here[/I][/COLOR]

</body>

<script>

[COLOR="#FF0000"][I]your JS here[/I][/COLOR]

</script
</html>

here is the function thts used
function SelectAll_G(G_Name)
{
var G_View = document.getElementById(G_Name);
if(GdView == null)
{
return false;
}
switch(G_View.id)
{

case document.getElementById(‘<%=Grid_details1.ClientID %>’).id:
{
alert(document.getElementById(‘<%=Grid_details1.ClientID %>’).id);
for(var child1 = 0; child1 <= G_View.childNodes.length-1;child1++)
{
var G_Child1 = GdView.childNodes(child1);
for(var child2 = 0; child2 <= G_Child1.childNodes.length-1;child2++)
{
// code for enabling / disabling controls
}
}
}
}
}

i hve this for only one grid currently
trying for multiple grids

function SelectAll_G(G_Name) // tried this
{
var G_View = document.getElementById(G_Name);
alert( document.getElementById(G_Name).id);
if(GdView == null)
{
return false;
}

for(var child1 = 0; child1 <= G_View.childNodes.length-1;child1++)
{
var G_Child1 = GdView.childNodes(child1);
for(var child2 = 0; child2 <= G_Child1.childNodes.length-1;child2++)
{
// code for enabling / disabling controls
}
}
}
}
}

Why not post some HTML, too, so people can see this in action—as described above.