While the answers above are correct, you have to be careful doing this kind of thing.
For example, let's say you click check2. He changes the action. You submit a form or navigate to another page. You will now click the Back button.
The browser reloads the page *, resetting the form action to the value specified in the HTML. But! Browsers remember the previous values set in the form fields, so check2 is still selected without receiving a click event: the state of the radio stations does not match the state of the action form.
To avoid such problems, you should always check the form values on page load and update whatever depends on them.
In general, you should try to have one action, and the host script server decides what to do, not change the action on the fly. This avoids errors like above and stops form breaking for non-JS UA.
*: Firefox cannot reload the page if it is still stored in the DOM cache of the loaded page.
source
to share