Jump to content

7.0 Redirect to 2 Different Pages Based on Form Answer

Recommended Posts

I'm trying to create two redirections depending on the answer to the radio question on this page: https://www.raddaconnect.com/start-application

When they choose “One Applicant,” I want it to redirect to this page after they click the Start Application button: https://www.raddaconnect.com/one-applicant-application

When they choose “Multiple Applicants (Ideal application for teachers and families with multiple applicants),” I want it to redirect to this page after they click the Start Application button: https://www.raddaconnect.com/multiple-applicants-application

I currently have a code block with the following code, but it doesn't redirect at all: 

<script>
function redirect() {
  var radioButtons = document.getElementsByName('radio-6f1d6d49682a9f0016b049c6b83d40c3');
  for (var i = 0; i < radioButtons.length; i++) {
    if (radioButtons[i].checked) {
      var value = radioButtons[i].value;
      if (value == 'One Applicant') {
        window.location.href = 'https://www.raddaconnect.com/one-applicant-application';
      } else if (value == 'Multiple Applicants (Ideal application for teachers and families with multiple applicants)') {
        window.location.href = 'https://www.raddaconnect.com/multiple-applicants-application';
      }
      break;
    }
  }
}
document.addEventListener('DOMContentLoaded', function() {
  var form = document.getElementById('block-yui_3_17_2_1_1649675282424_10012');
  form.addEventListener('submit', function(event) {
    event.preventDefault();
    redirect();
    form.submit();
  });
});
</script>

 

Any help would be greatly appreciated! Thanks in advanced!

Edited by meeshell638
Fixing a typo
Link to comment
  • Replies 0
  • Views 109
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Create an account or sign in to comment

You need to be a member in order to leave a comment


×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.