Reputation: 2261
<tr>
<td><c:out value= "${l+1}" /></td>
<td><c:out value="${list.name}" /></td>
<td><c:out value="${list.size} MB" /></td>
<td><img class='imagem_artigo' src='data:image/png;base64,${list.previewUrl}' alt='IMG DESC' width="200" height='200'></td>
<td><i class="material-icons">edit</i></td>
<td><i class="material-icons">delete</i></td>
</tr>
I have two icons , for edit and delete . Now I need to fetch the row index so that I can write the onclick function for them.I am using hibernate so I need to fetch the image name so that I can delete it in the database. I'll write the hibernate query in the servlet but I need to send the name of the image to that servlet.
I tried using nashorn.
<td><i class="material-icons" onClick='<% nashorn.eval("var i = $(this).closest('td').parent()[0].sectionRowIndex; window.location='http://localhost:8080/AdvanceJavaAssignment2/processing.jsp?param=i';"); %>'>edit</i>
But this code is not working . Can anyone explain a more efficient and a better way to solve this problem ?
Upvotes: 1
Views: 1403
Reputation: 533
<button class='delete_click' value="${list.name}">delete</button></td>
$(".delete_click").on('click', function(e){
var u = $(e.currentTarget).val();}
or
var u = $(e.currentTarget).closest('td').parent()[0].sectionRowIndex ;}
You can try this
Upvotes: 2