Here you go, this should work just fine.. I set the name and created a method for counting the checkboxes as you create them. The number is then appended to the name of the checkboxes to you would references them by their number. In this way, each checkbox will indefinately have a unique name for which you can refer to in your php script. Note that the number appended to the name is kept track of using a hidden form field.
first checkbox created = 0, second = 1, etc (or you could replace the hidden form field's value with "1" - then first checkbox created = 1
..Well, you get the idea, i'm sure!
-
<html>
-
<head>
-
<script language="Javascript">
-
-
function append()
-
{
-
var i = parseInt(document.getElementById( "iCheckboxes" ).value);
-
var cb = document.createElement( "input" );
-
cb.type = "checkbox";
-
cb.id = "id"+i;
-
cb.name = "name"+i;
-
cb.value = "test";
-
cb.checked = true;
-
var text = document.createTextNode( "checkbox" );
-
document.getElementById( 'append' ).appendChild( text );
-
document.getElementById( 'append' ).appendChild( cb );
-
document.getElementById( "iCheckboxes" ).value = parseInt(document.getElementById( "iCheckboxes" ).value) + 1;
-
}
-
-
</script>
-
</head>
-
<body>
-
<p>click the button below</p>
-
<form action="http://localhost/test.php" name="form" id="form" method="post" enctype="multipart/form-data">
-
<div id="append" name="append">Append here</div>
-
<input type="hidden" value="0" name="iCheckboxes" id="iCheckboxes">
-
<input type="button" value="append" onclick="javascript:append()" />
-
<input type="submit" value="submit" />
-
</form>
-
</body>
-
</html>
-