Instead of a button, an onObjectSave (drop downs) or OnObjectModify(pop up menu) script trigger can be used.
Ok but what function do I use to actually set a variable to the value of the dropdown. Example please. Thanks.
First you'll need to define a field for use with the drop down list. Let's call it Table::DropDown
Then your script uses a single script step (Not a function) to copy the value of the drop down field into the variable:
Set variable [$$DropDown ; value: Table::DropDown]
Note: variables starting with $$ are global variables that will be accessible from any script on any layout in your file and the value in the variable will be retained for as long as the file is open. If you start the name with $ you have a script variable and the value will exist only within the context of the currently executing script. Once the script ends, the value is lost.
You'll need to decide which option works for what you want to do.