There are two issues you have to deal with.
First, what page are you on and what is being displayed? You can press a button to increment the counter using script and the API but if the field value is being displayed on the current page you have to somehow deal with the issue of displaying the new value of the counter so as to not confuse your users.
Second, you first need to get the current value of the counter from the page you are on or through the API then increment and save the counter using API_EditRecord.
The script is simple but you have to define the workflow you want.
This is the essential part of the code to increment a [counter] field with fid=6: