Created
July 19, 2023 09:54
-
-
Save dan-donica/44379c41b737d8d45961c3b04f8fde13 to your computer and use it in GitHub Desktop.
HC || Redirect depending on dropdown
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Begin "Redirect depending on dropdown" || Help center --> | |
<!-- Insert in Settings->Javascript->Header --> | |
<!-- CS:20200120-11-1 --> | |
<script> | |
document.addEventListener("DOMContentLoaded", function() { | |
var dropdownName = "My Dropdown"; // Field name | |
var options = { | |
"Option 1": "https://instapage.com", // Each option on a new line | |
"Option 2": "https://help.instapage.com/hc", | |
"Option 3": "https://help.instapage.com/hc/en-us/articles/214133067" | |
// "Option Name" : "Redirect URL if this option is chosen" | |
} | |
var selectInput = document.querySelectorAll('form select[name="' + dropdownName + '"]'); | |
window.instapageFormSubmitSuccess = function() { | |
for (var i = 0; i < selectInput.length; i++) { | |
var selectedOption = selectInput[i].value; | |
document.querySelectorAll('input[name="redirect"]')[i].value = options[selectedOption]; | |
} | |
} | |
}); | |
</script> | |
<!-- End "Redirect depending on dropdown" || Help center --> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://help.instapage.com/hc/en-us/articles/214133067-Redirect-to-a-different-page-depending-on-the-dropdown-option-selected