Popup radio form - Redirect to a specific URL on submit based on radio selection


#1

We have two product options (one-time and subscription) and we would like to redirect the user to a specific URL based on their radio selection when they hit the submit/buy button. These options are being displayed inside of a Unbounce Popup.

From my understanding this isn’t possible inside of Unbounce without some sort of custom JavaScript or a third-party form. We’ve got a switch statement working when the radio button is chosen but it happens immediately, and we would like this to be based off the submit button click.

Below is the switch statement we are working with and we just need to find a way to wrap, or base it off a submit/click function. Regular submit/click functions don’t seem to be working we think because of limitations on the Unbounce platform.

<script>

$(“input[name=‘productoption’]:checked”).live(‘change’, function() {

switch ($(this).val()) {

case 'Subscribe & Save':
    window.parent.location.href = "our unique URL A";
    break;
case 'One-Time Purchase':
    window.parent.location.href = "our unique URL B";
    break;

}

});

The above code is working when the user selects a radio button but it happens immediately, rather than when the submit button is clicked.

Thank you in advance!


#2

Apparently my code has been working this whole time. Probably a cache issue or something. Hopefully this helps someone trying to accomplish the same thing. Again, this redirects the user to a specific URL based on radio selection.

<script>
$("input[name='productoption']:checked").live('change', function() {
  switch ($(this).val()) { 
    case 'Subscribe & Save':
        window.module.lp.form.data.confirmData = "our unique URL A";
        break;
    case 'One-Time Purchase':
        window.module.lp.form.data.confirmData = "our unique URL B";
        break;
  }
}); 
</script> 

The only thing that changed from my previous post was the line starting with “window.module…” and the reason I had changed that initially was because it was loading the external URL inside of the modal window, so I was attempting to load it inside of the parent.

Make sure you modify [name=""] to match your radio button input name. And “Subscribe & Save” represents the value of the radio button input.

  • Cheers