To change action value of form dynamically, you can try below code:
below code is if you are opening some dailog box and inside that dailog box you have form and you want to change the action of it. I used Bootstrap dailog box and on opening of that dailog box I am assigning action value to the form.
$('#your-dailog-id').on('show.bs.modal', function (event) {
var link = $(event.relatedTarget);// Link that triggered the modal
var cURL= link.data('url');// Extract info from data-* attributes
$("#delUserform").attr("action", cURL);
});
If you are trying to change the form action on regular page, use below code
$("#yourElementId").change(function() {
var action = <generate_action>;
$("#formId").attr("action", action);
});