I am facing an issue with my JSP page where I need to pass a username from a button click to a modal window and then send it to the back-end (struts2 action). The scenario is depicted in the image below.
I attempted to pass the username using onClick:
<%-- Page.jsp --%>
<button onclick="document.forms[0].username.value='BOB'; toggle="modal" data-target="#myModal">
<fmt:message key='Delete user'/>
</button>
<jsp:include page="deleteUserModal.jsp"/>
In the modal, I want to retrieve the username value:
<%-- Modal.jsp --%>
<button onclick="document.forms[0].username.value='???';document.forms[0].action='deleteMethod';document.forms[0].submit();">
<fmt:message key='delete'/>
</button>
If you have any suggestions or ideas on how to achieve this, please let me know,