I have the following html code:

Code:
<table>
...
<tr id="InputRow">
  <td>
    <input type="text" name="..." value=""/>
    <span>
     </span>
  </td>
</tr>
</table>
and JavaScript code:

Code:
function AddRow(far)
{
var rowclone=$('#InputRow').clone(); //clone the row
for (i=0; i<far.length; i++)
    {
    if (i == 0)
        {
        $('#InputRow').find('input').val(far[i]['id']);
        $('#InputRow').find('span').html(far[i]['fname']);
        }
    else
        {
        rowclone.find('input').val(far[i]['id']);
        rowclone.find('span').html(far[i]['fname']);
        $('#InputRow').nextAll("tr:last").after(rowclone); //insert a new row after the existing at the end
        }
    }
}

$(function()
{
AddRow(ar); //JSON object with a simple array
}
);
So what I need to do is to simply clone the row, substitute new values from an array and insert it at the end of existing row (if array's size more then 1). But this doesn't work! Where is an error?