CMS Development

Woodsy
Colaborador líder

Form with Multiple Redirects

Is there a way of adapting @anders_grove code for two sets of radio buttons that covers the various permutations of input?

 

<!--[if lte IE 8]>
<script charset="utf-8" type="text/javascript" src="//js.hsforms.net/forms/v2-legacy.js"></script>
<![endif]-->
<script charset="utf-8" type="text/javascript" src="//js.hsforms.net/forms/v2.js"></script>
<script>
hbspt.forms.create({
portalId: "xxxxxxx",
formId: "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
css: "",
onFormSubmit: function($form) {
var choice = $('input[name="redirect_choice"]:checked').val();
if (choice == 'Redirect 1') {
window.location = 'http://www.example-1.com';
} else if (choice == 'Redirect 2'){
window.location = 'http://www.example-2.com';
} else if (choice == 'Redirect 3'){
window.location = 'http://www.example-3.com';
}
} 
});
</script>

The code supplied by anders_grove is for one question with a set of radio buttons. I'm trying to create a similar thing with two sets of radio buttons. In effect 2 questions, one question with 3 radio buttons and another question with 6 radio buttons.

 

Thanks

0 Me gusta
1 Respuesta 1
narmstrong
Colaborador | Partner nivel Platinum
Colaborador | Partner nivel Platinum

Form with Multiple Redirects

<!--[if lte IE 8]>
<script charset="utf-8" type="text/javascript" src="//js.hsforms.net/forms/v2-legacy.js"></script>
<![endif]-->
<script charset="utf-8" type="text/javascript" src="//js.hsforms.net/forms/v2.js"></script>
<script>
hbspt.forms.create({
portalId: "xxxxxxx",
formId: "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
css: "",
onFormSubmit: function($form) {
var choice1 = $('input[name="redirect_choice_1"]:checked').val();
var choice2 = $('input[name="redirect_choice_2"]:checked').val();
var choice = choice1+' '+choice2; if (choice == 'Redirect 1') { window.location = 'http://www.example-1.com'; } else if (choice == 'Redirect 2'){ window.location = 'http://www.example-2.com'; } else if (choice == 'Redirect 3'){ window.location = 'http://www.example-3.com'; } } }); </script>

 A couple more details would be helpful in getting a better piece of code. But the above will put your two sets together. You can then add the values as needed to get your correct redirect. 

 

Best regards

Noah Armstrong | TSL Marketing
Senior Developer
6085 Marshalee Dr| Suite 100 | Elkridge, MD 21075
Contact Us

TSL Marketing