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 variables 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...