There is a form containing two buttons. And then I suppose that when I click different buttons, a relevant message box will be popped up. Once the button is clicked, it will trigger a further action called "Approval".
However, at the current situation, the alert box only shows one status. I know the current status are getting the same ID and it is a wrong operation. But I don't know the solution now. Could anyone help me?
I looked into this ref: Form onSubmit determine which submit button was pressed, but could not quite understand the concept the solution provided.
<script type="text/javascript" language="javascript">
function ConfirmOnDelete() {
var a = document.getElementById('a_action').value; //I want to change this
if (a == "Approve")
{
if (confirm("Are you sure to approve?") == true)
return true;
else
return false;
}
else
{
if (confirm("Are you sure to delete?") == true)
return true;
else
return false;
}
}
</script>
<form id="Batch" action="Approval" method="post" onsubmit="return ConfirmOnDelete();">
@<text>
@If ViewBag.unapprovedCount > 0 Then
@<div style="float: left;">
<br />
<input type="hidden" name="batch_action" value="Delete" />
<input type="hidden" id="a_action" name="additional_action" value="Delete" />
<input type="submit" id="submit4" name="submit" class="button" value="Delete" style="width:100px;">
</div>
End If
@If ViewBag.unapprovedCount > 0 Then
@<div style="float: right;">
<br />
<input type="hidden" name="batch_action" value="Approve" />
<input type="hidden" id="a_action2" name="additional_action" value="Approve" />
<input type="submit" id="submit3" name="submit" class="button" value="@ViewBag.batch_action" style="width:100px;">
</div>
End If
</text>
</form>