Quite a few problems here.
<tr id="500">
<form id="500" onsubmit="DoThis()">
You can't have an ‘id’ beginning with a number. You can't have two identical ‘id’ values in the same document. You can't have <form> directly inside a <tr>, which is what's causing the problem here. For me, even the first form doesn't work.
var TrElement = document.getElementById("500")
Which one?
var parent = TrElement.parent;
Should be parentNode.
var NewTr = TrElement.cloneNode(true);
parent.appendChild(NewTr);
You now have another two elements with id="500"! You should change the IDs of cloned elements before appending them to the document.
There are a few approaches you can take here. If all the form fields are in a single cell, you can just put the form inside the cell. If, however, you need fields across multiple cells then the form has to go outside the table.
In that case you could either have a single form outside the entire table, or one form pre row, each containing a separate <table>. You can make all the tables' columns line up by using specified-width columns and the CSS rule “table-layout: fixed”.
(Do you even need a form at all? There may be code missing in your example, but as it is you're not even using the form to submit to anywhere. If your page is supposed to be purely javascript, you can completely omit the form and just put onclick events on buttons.)
Assuming you do need multiple forms, here's some example code:
<div>
<form method="post" action="setThing.script" class="setform" id="setform-500">
<table><tr>
<td>Info</td>
<td><input type="text" name="setting" value="" /></td>
<td><input type="submit" value="Set" /></td>
</tr></table>
</form>
</div>
<button id="addrow">Another one, please!</button>
<script type="text/javascript">
function doThing() {
alert('validating form or something');
return false;
}
var rownum= 500;
document.getElementById('setform-'+rownum).onsubmit= doThing;
document.getElementById('addrow').onclick= function() {
var f500= document.getElementById('setform-'+rownum);
var fnew= f500.cloneNode(true);
rownum++;
fnew.id= 'setform-'+rownum;
fnew.onsubmit= doThing;
f500.parentNode.appendChild(fnew);
}
</script>