JSP form with two action buttons

jsp

I create inside a JSP a form and i'm having inside it 2 buttons.

<form:form method="POST" action="${pageContext.request.contextPath}/firstAction>
     <tr>
        <td>Input</td>
        <td><form:input path="input" /></td>

         <td>data</td>
         <td><form:input path="data"/></td>

        <td>
            <input id="delete" class="myclass" type="image" src="${pageContext.request.contextPath}/<spring:theme code="image"/>delete.jpg" value="delete" alt="delete" title="delete" /
        </td>

        <td>
            <input id="Approve" class="myclass2" type="image" src="${pageContext.request.contextPath}/<spring:theme code="image"/>approve.jpg" value="Approve" alt="Approve" title="Approve" />
        </td>
     </tr>
</form:form> 

I want when a user click at the one button to call the URI /firstAction and when click at the second button to make another action in a different URI. But i want to provide the dispayed data and the buttons in the same table. And also i need both input and data inputs in the actions i want to make.

P.S. Actually now when i pressing at both buttons i'm redirecting at the /firstAction and this is normal as i have it in the same form.

Best Answer

You can use jQuery to achieve this. Something like this should do the work:

$('#delete').click(function(e){
        $(this).parent('form').attr('action', '/firstAction');
});

$('#Approve').click(function(e){
        $(this).parent('form').attr('action', '/secondAction');
});