Change the redirect URL of a submit button depending on the radio selection from a user

It’s possible using some custom code. Just replace the ID of the button with whatever you’ve set as the ID, and add the values for the radio buttons under Option1, Option2, etc.

const button = document.getElementById('button');
const radioButtons = document.getElementsByName('radioButtons');

// Add change event listener to radio buttons
radioButtons.forEach(radioButton => {
  radioButton.addEventListener('change', updateButtonURL);
});

// Function to update the URL of the button
function updateButtonURL() {
  let selectedValue = '';

  // Find the selected radio button
  radioButtons.forEach(radioButton => {
    if (radioButton.checked) {
      selectedValue = radioButton.value;
    }
  });

  // Update the URL based on the selected value
  switch (selectedValue) {
    case 'option1':
      button.setAttribute('onclick', 'location.href = "https://example.com/url1";');
      break;
    case 'option2':
      button.setAttribute('onclick', 'location.href = "https://example.com/url2";');
      break;
    case 'option3':
      button.setAttribute('onclick', 'location.href = "https://example.com/url3";');
      break;
    default:
      // Default URL if no option is selected
      button.setAttribute('onclick', 'location.href = "https://example.com/default";');
  }
}