Allow multiple fields to be incremented properly

I've wrapped the $input in an each loop to capture all the fields that would be cloned and this would make way to multiple fields being cloned properly in terms of name and id field.

Initially, the current javascript code treats multiple fields to have the same input name and id.

So if there is this fields:
<input type="text" name="field[0][url]" value="" />
<input type="text" name="field[0][name]" value="" />

If cloned, it would end up like this:
<input type="text" name="field[1][url]" value="" />
<input type="text" name="field[1][url]" value="" />

The above proposed fix will fix this issue.