<script>
..........//some code//
//here s will be incresed in runtime
var oC2TD = oTR.insertCell(1);
		oC2TD.innerHTML = "<input type=text class=text_box2 autocomplete=off name=txtCatgName"+s+" id=select"+s+"/>";

alert(document.getElementById('select'+s+''))
[B]//for above alert iam getting null
//but when i replace "select" with text box name like txtCatgName
//iam getting object and i replace in below line too, but, if i replace like that, iam not getting customarray data into object in the below line[/B]
var obj = actb(document.getElementById('select'+s+''),customarray);	

</script>

i did this in my previous java program, its working, but in other prgrm it's not working

Here's a simple demo, that will evaluates all ids of created elements.

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">
<html id="html40L" lang="en">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Content-Style-Type" content="text/css">
<meta http-equiv="Content-Script-Type" content="text/javascript">
<meta http-equiv="Window-target" content="_top">
<title>Free Live Help!</title>
<style type="text/css">
<!--

-->
</style>
<script type="text/javascript">
<!--
var obj = function() {

   var oC2TD = (( document.getElementById ) ? document.getElementById("mydiv") : document.all.mydiv ); // Assuming that this the table-cell.

   var hold = document.createDocumentFragment();
   for ( var x = 0, y = 0; x < 2, y < 3; x++, y++  ) {
   input = document.createElement("input");
   input.id = "select" + y;

   input.type = "text";

   hold.appendChild( input );

   oC2TD.appendChild( hold );
   alert((( document.getElementById ) ? document.getElementById("select" + x ) : document.all["select" + x ]).id );  
   }        
};
window.onload = obj;
// -->
</script>
</head>
<body>
<div id="mydiv"></div>
</body>
</html>

I think the problem with your code, is that the variable s is incremented more than the numbers of elements created inside your table-cell. But this can be fixed, doing this format:

alert( document.getElementById("select" + (( s ) - 1 )));

hope it helps...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.