<tr>
<td><input name="of[1][dsn]" type="text" size="6" /></td>
<td><input name="of[1][gc]" type="text" size="6" /></td>
<td><input name="of[1][ys]" type="text" size="3" /></td>
<td><input name="of[1][ym]" type="text" size="3" /></td>
<td><input name="of[1][yl]" type="text" size="3" /></td>
<td><input name="of[1][s]" type="text" size="3" /></td>
<td><input name="of[1][m]" type="text" size="3" /></td>
<td><input name="of[1][l]" type="text" size="3" /></td>
<td><input name="of[1][xl]" type="text" size="3" /></td>
<td><input name="of[1][xxl]" type="text" size="3" /></td>
<td><input name="of[1][xxxl]" type="text" size="3" /></td>
<td><input name="of[1][xxxxl]" type="text" size="3" /></td>
<td><input name="of[1][xxxxxl]" type="text" size="3" /></td>
<td><input name="of[1][total]" type="text" size="4" /></td>
</tr>
I currently have this being cloned using jQuery and would like to have it to where the number in the "name" attribute is raised by +1 every time it is duplicated. "of[1][dsn]" to "of[2][dsn]" etc. How can I do this? Below is what I had tried to use, but that was flat out replacing what was already there.
("input").each(function(index, element){$(element).attr("name", index);});
This is what I am using to actually clone the table row:
var clonedRow = $("table tr:last").clone();
$("table tr:last").clone(true).insertAfter("table tr:last").append(clonedrow);