JSP

Determine which button is clicked in the JSP for loop


1. When making the message board, I encountered the for loop in the database and decided which button was clicked.

2. Click to enter js method


<script>
function method(id){
alert(id);
}
</script>

<%for(User u:list){%>

<input type="button" id=<%=u.getId() onclink="method('"<%=u.getId()%>"')"%>

<%}%>

3. See the assembly method in onclink clearly first ’, then ’.