Reputation: 4563
I have a javascript function that I need to call on click of the delete button -
JavaScript:
function test(var1) {
alert(var1);
}
JSP code (logs
is an ArrayList
of length 10):
<table>
<%
for(int i=0; i<len; i++)
{
%>
<tr>
<td><%out.println(logs[i].getItemName());%></td>
<td><%out.println(logs[i].getItemDesc()); %></td>
<td> <input class="submit" type="submit" value="Delete" onclick="test(<%logs[i].getItemName();%>);"/></td>
</tr>
<%
}
%>
</table>
This will print the output as -
Name1 Description1 Delete_Button
Name2 Description2 Delete_Button
.
.
Name10 Description10 Delete_Button
I am not getting how to send the correct itemname value to the JavaScript, when I click on a corresponding row's delete button. Currently I am getting the value as undefined in the JavaScript alert when I click any of the delete buttons.
Upvotes: 0
Views: 4960