I want to delete the selected row on click of my delete button. My delete functionality is working fine the problem I am facing is only top most delete button is working my UI screen looks like below

I select the table rows using the checkboxes. If I select all three records all three delete button should work and any delete button can delete the selected rows but in my case only first delete button is working. This is my html and js code.
<td class="td-org">${entry.sORGID}</td>
<td class="td-org">${entry.url}</td>
<td class="td-org">${entry.type}</td>
<td class="td-org"><a href="" onclick="testing("")" />Testing</td>
<td class="td-org"><input type="button" value="Delete" id="btntest" />
document.getElementById('btntest').onclick = function(){
var selchbox = getSelectedChbox(this.form); // gets the array returned by getSelectedChbox()
var myvalue = JSON.stringify(selchbox);
//document.write("check check"+selchbox);
$.ajax({
type: "POST",
url: "/delete",
dataType : "JSON",
contentType:"application/json; charset=utf-8",
data: JSON.stringify(selchbox),
cache: false,
success: function (data) {
alert("SUCCESS!!!");
},
error: function (args) {
alert("Error on ajax post");
}
});
//alert(selchbox);
}
getSelectedChbox code
function getSelectedChbox(ele) {
var selchbox = []; // array that will store the value of selected checkboxes
// gets all the input tags in frm, and their number
var inpfields = ele.getElementsByTagName('input');
var nr_inpfields = inpfields.length;
// traverse the inpfields elements, and adds the value of selected (checked) checkbox in selchbox
for(var i=0; i<nr_inpfields; i++) {
if(inpfields[i].type == 'checkbox' && inpfields[i].checked == true) selchbox.push(inpfields[i].value);
//selchbox = JSON.stringify({'selchbox' : selchbox});
}
return selchbox;
}
In controller i am performing delete
What i am missing here?