Call the function with a parameter that identifies the button.
In your XSLT, generate the code for the function call to include a value for this parameter, eg..
<button onClick="process-button({position()})">
Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference