Basically, you can't show the button and update the meta at the same moment. This has to be done in two separate requests as follows:
Show the button whereever you want. It needs to be a form that submits to the same page (or an ajax call to another URL, but let's keep it simple for now).
Read the value posted from the form.
Here is a simple implementation ...