How to alter and manipulate the behavior and action of button through extension?
you can use hook_civicrm_postProcess or hook_civicrm_post

which ever you need based on your requirement below is the link for more reference http://wiki.civicrm.org/confluence/display/CRMDOC/Hook+Reference