I am trying to trigger the submit of a form from a link outside the form (not the submit button).
Here is the basics of the form:
<form action="/Hospice/TabPatientTrackingPost" id="formTabPatientTrackingPost" method="post">
[a big form with lots of inputs]
<div class="pull-right">
<button type="submit" class="btn btn-brand" id="btnSave" name="btnSave">Save</button>
<button type="reset" class="btn btn-brand" id="btnCancel">Cancel</button>
</div>
</form>
Here is what the link looks like:
<a href="/Hospice/TabLiving/1" onclick="triggerSave();">Living</a></li>
JS Function:
function triggerSave() {
alert("triggerSave test alert");
$("#formTabPatientTrackingPost").submit();
}
But, the code $("#formTabPatientTrackingPost").submit();
is not causing the form to post the submit.
The alert("triggerSave test alert");
is firing, but the form is not submitting.
It works fine if I just click the Save button.
Any ideas what I am doing wrong?