I have a form like this
First get your input, and then update the action. Return true if you want to form to submit after changing the value, or false if these are separate buttons.
Be careful doing things like this, as if you use this solution you will be opening yourself up to javascript injection attacks. You'll want to "scrub" your input before injecting it into your form.