CMS Development

RBradford
Member

Conditional Logic Redirect on Form Submission

So I know that there's a ton of disussion around this already, but I've dived in and continueally run into issues getting it to actually work. Here's what I have:

script charset="utf-8" type="text/javascript" src="//js.hsforms.net/forms/embed/v2.js"></script>
<script>
  hbspt.forms.create({
    region: "na1",
    portalId: "XXXXXXXX",
    formId: "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
  onFormSubmit: function($form) {
var choice = $('input[name="accredited_investor"]:checked').val();
if (choice == 'Yes I qualify as an accredited investor') {
window.location = 'https://www.wefunder.com/atakama/invest?amount=10000';
} if (choice == 'No I do not qualify as an accredited investor'){
window.location = 'https://invest.atakama.com/sorry';
}
} 
});       
</script>

 

Any Ideas? I'm really needing to get this working ASAP.

0 Upvotes
2 Replies 2
LeeBartelme
HubSpot Employee
HubSpot Employee

Conditional Logic Redirect on Form Submission

https://community.hubspot.com/t5/APIs-Integrations/Redirecting-Hubspot-form-to-different-urls-depend...

 

You can't reference the form fields directly. See my answer and the reason why. You must get the from the $form object.

0 Upvotes
Jaycee_Lewis
Community Manager
Community Manager

Conditional Logic Redirect on Form Submission

Hi, @RBradford 👋 Thanks for providing your example. Hey, @Teun @LeeBartelme, do you have any quick tips for @RBradford?

 

Thank you! — Jaycee

linkedin

Jaycee Lewis

Developer Community Manager

Community | HubSpot

0 Upvotes