I’m trying to redirect the user to different URLs based on the values in two different drop downs. I successfully coded the redirect of field values in one drop down but can’t figure it out with two. I started the redirects by building out the redirects of field_2 before realizing I needed another qualifying question so I added field_1.I changed the values in the example to be super broad and unidentifiable to my business.
Basically, if someone says “No” to field_1 regardless of what’s in field_2, I want to send them to URL_4. The same goes for if someone says “Yes” to field_1 but “None of the above” to field_2. For everything else, someone must say “Yes” to field_1 with either option 1, 2, or 3.
Field Example:
Field ID: field_1
Values:
Yes
No
Field ID: field_2
Values:
Option 1
Option 2
Option 3
None of the above
Here’s my original script for just the field_2 before I added the other question that worked.
<script>
$("#field_2").on('change', function() {
switch ($(this).val()) {
case 'Option 1':
window.module.lp.form.data.url = "https://test.com/URL_1";
break;
case 'Option 2':
window.module.lp.form.data.url = "https://test.com/URL_2";
break;
case 'Option 3:
window.module.lp.form.data.url = "https://test.com/URL_3";
break;
case 'None of the above':
window.module.lp.form.data.url = "https://test.com/URL_4";
break;
}
});
</script>