you was almost there.
Just change the Javascript part where you assign the name
attribute, including the index exactly as you do in the iteration:
item.name="id.item";
specification.name="id.specification";
// ecc...
must become
item.name="id["+counts+"].itemname";
specification.name="id["+counts+"].specification";
And you will be good.