Is it possible to have a single instance of a button but change its action dynamically by clicking another button?

If so can someone give me a nudge in the right direction on the scripting for this:-)