since the javascript call won't pick up the name or id of the link clicked, you'd have to change your code to something similar and have a javascript function handle the submit and the link name bits:
<a name="change_cart_contents" id="change_cart_contents" href="#" onClick="submitAddressForm(document.address_form,this.name);" class="button">change cart contents</a>
<script language="JavaScript">
function submitAddressForm(addressForm,linkName){
//do something with the name of the link
alert(linkName)
addressForm.submit()
}
</script>
or
since onClick happens first (before the page will go to the href target. Try it with onClick='return false'), you could have it set a form field to hold that value before the form get submitted with:
onClick="document.address_form.linkName.value=this.name"
and keep your href=javascript:... bit as you currently have it.