How to change the action value?

Hello. As possible depending on the selected radio to send the form to a particular processor.
For example, you have 2 radio
<input type="radio" name="ky" checked> Pay by card<br>
<input type="radio" name="ky"> an invoice<br>

When you select "Pay by card" and clicking the button form is submitted to form.php and when you select "issue invoice" and clicking the button on form1.php. How this can be implemented? Thank you.
June 27th 19 at 15:13
2 answers
June 27th 19 at 15:15
On input to add the attribute value or, for example,
First input: data-form="form.php"
Second: data-form="form1.php"
And the form tag, for example, there is aydishnik #form

On jQuery
$('[name="ky"').on('change', function () {
var actionLink = $(this).data('form');
$('#form').attr('action', actionLink);

Sorry for no formatting. Writing to the phone.
June 27th 19 at 15:17
if you have jquery it is better that this method, so the request won't reload the page, and will not have to break a few html forms.

<div id="card" style="margin-left: 50px; margin-bottom: 50px">
 <label class="radio-inline"><input type="radio" name="closed" value="0">Cheque</label>
 <label class="radio-inline"><input type="radio" name="closed" value="1">a Map</label>

$(document).ready(function () {
 $('#closed').change(function () {
 sendto($("#card input:radio:checked").val());
 function sendto(card) {
 if (card){
 type: "GET",
 url: 'form.php',
 data : {card: card},
 success: function(data){
 data = $.parseJSON(data);
 // data in the server's response
 error:function (request, err, ex) {
 //here ajax request to another address

Find more questions by tags HTMLJavaScriptPHP