One possible solution is to override the onclick event of the link, so that you can submit the form to the server with additional hidden information that specifies which link was clicked.
Another solution is to use Ajax to retrieve additional information from the server so that you can update parts of the page without needing to reload the entire page.
It will b something like: (not fully tested!)
Form
====
<form id="aform" method="post">
<p><label>A label: <input name="aname" value="a value"></label></p>
<p>
<input type="hidden" name="link">
<input type="submit" name="submit" value="Submit">
</p>
</form>
Link
====
<a id="alink" href="#ImALink">A link</a>
JavaScript
==========
document.getElementById('alink').onclick = function () {
// the this keyword is a reference to the clicked-on link
var form;
form = document.getElementById('aform');
form.elements.link = this.href;
form.submit();
};