Skip to content

Instantly share code, notes, and snippets.

@RobertCam
Last active March 21, 2024 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save RobertCam/15990124d7b9622e0503422e7305c8c5 to your computer and use it in GitHub Desktop.
Save RobertCam/15990124d7b9622e0503422e7305c8c5 to your computer and use it in GitHub Desktop.
Have an Unbounce form redirect to different URLs based on a dropdown selection
<script>
/*
Unbounce Community :: Tips & Scripts :: Dynamic Form Confirmation URL's Using Browser Redirects
TS:0002-04-051
***********************
Do not remove this section. It helps our team track useage of external workarounds.
*/
var url = $("#destination");
var formDestination = document.getElementById('form_destination'); // Add ID of dropdown field
// Add URLs for dropdown options
destination1 = 'community.unbounce.com';
destination2 = 'unbounce.com/blog/';
destination3 = 'google.ca';
$(formDestination).change(function() {
if (formDestination.selectedIndex == 1) {
$(url).val(destination1);
} else if (formDestination.selectedIndex == 2) {
$(url).val(destination2);
} else if (formDestination.selectedIndex == 3) {
$(url).val(destination3);
}
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment