```
    $(document).ready(function(){
        var srno=1;
        var srnoarray= new Array();
        $(".addRow").click(function(){

            var ToAppend='<tr><td><input type="text" class="form-control" style="width:40px;" name="srno_[]" id="id_srno_'+srno+'" value="'+srno+'" readonly="readonly"  /></td>';

            ToAppend+='<td>';
            ToAppend+='<select class="form-control" name="product_name_'+srno+'" id="product_name_'+srno+'" onchange="return onSelectChangeajax(this.value,'+srno+')">';
            ToAppend+='<option value="0">Select Product</option>';
            ToAppend+='</select>';
            ToAppend+='</td>';

            ToAppend+='<td><input type="text" class="form-control" name="product_prise_'+srno+'" id="product_prise_'+srno+'" placeholder="Purchase Prise" onblur="calAmount('+srno+')" /></td><td><input type="text" class="form-control" name="product_qty_'+srno+'" id="product_qty_'+srno+'" value="1" placeholder="Quantity" onblur="calAmount('+srno+')"/></td><td><input type="text" class="form-control" name="product_amt_'+srno+'" id="product_amt_'+srno+'" placeholder="Amount" onblur="calAmount('+srno+')"/></td><td><img src="dist/img/removerow.png" onclick="deleteRow(this),deleteArrayVal.apply(this,'+srnoarray+');" /></td></tr>';
            srnoarray.push(srno);
            $("#purchaseItems").append(ToAppend);

            console.log(srnoarray);
            srno++;
        });

});

function deleteRow(rwo)
{   
    var i=rwo.parentNode.parentNode.rowIndex;
    document.getElementById("purchaseItems").deleteRow(i);
}
function deleteArrayVal(val)
{
    console.log(val);

}

```

Above functions add the dynamic row and remove the row in table. I have created an array called srnoarray and I have added srno in that array on every tr get added dynamically. deleteRow is the function to remove tr, **but when i remove tr i want to remove particular srno from srnoarray.**

```
<img src="dist/img/removerow.png" onclick="deleteRow(this),deleteArrayVal('+srnoarray+');" />

```

I tried passing array as argument in the function but that is not of use.
how should I do that??